Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Rich Text Editor in Multiple Metaboxes? WordPress

  • SOLVED

<strong>The scenario:</strong>
I have custom content (post) types that need multiple metaboxes with textareas using the rich text editing features of the TinyMCE editor.

<strong>The problem:</strong>
You can scour the Codex and all the blog posts in the world, but nothing provides a good enough resource to be able to replicate it. Even the best plugin developers have shied away from this.

<strong>What is needed:</strong>
A <em>well</em> documented answer that is easily replicated. I'm assuming the formatted content within the textarea of the TinyMCE editor metabox could be stored as a value in custom fields - please explain why this is or is not the case.

<strong>What will be done with your fine, fine answer:</strong>
I'll use it. I'll cite your brilliance in anything I use it in (posts, projects, yada, yada). I'll include it in a custom content framework plugin I'm creating to teach others how to do this.

Answers (4)

2010-07-24

Scott Clark answers:

Just FYI, it's impossible to have multiple TinyMCE editors (with media bar and html / visual tabs) in WP right now. Now that that's out of the way, it is possible to have multiple TinyMCE editors (with media bar and html / visual tabs) using some custom code.

If you want it, just go to [[LINK href="http://podscms.org/packages/tinymce-for-pods/"]]http://podscms.org/packages/tinymce-for-pods/[[/LINK]]

There's a plugin there that contains a function called "pods_tinymce" which will allow for multiple editors. It's got some custom js / css too.

Now as far as implementing and customizing further, you're on your own unfortunately as I've got some prior commitments for this week. I'm not looking for $10, just hope this helps. Good luck with everything ;)


Scott Clark comments:

@paul de wouters answer towards Kyle:

You should check that plugin out and see if you can use the TinyMCE code it's using in your own stuff. It may be using a similar solution to the one I've come up with for the TinyMCE for Pods.


Kyle Jones comments:

Thanks, Scott.
I'll see what I can gather from your work and the Custom Field Template.

Good luck with Pods!


Scott Clark comments:

BTW, I'm saying "impossible" as in, "impossible". I've spent countless hours with all the built-in functions and it's an issue with the custom JS integration WP is using, it's not coded with multiple editors in mind (html / visual box is bugged as well as the media bar)


Kyle Jones comments:

Yea, I remember reading one of your posts in the support forums to that effect (interestingly, that topic was closed for some reason...). Actually, it was one of the biggest reasons I posted here - I wanted to see if we couldn't pull more people out of the woodwork to take a look at this.

Sometimes I wonder why "they" make it so difficult to add additional CMS components into WP?

Alas...


Scott Clark comments:

I'm hoping to make my code eventually as a patch on that ticket

2010-07-24

wjm answers:

i have the code that you need since I created it for another project,
give me a few hours to get back to you on this,
also if you can reaise a little bit the prize, it would be good.

- wjm


Kyle Jones comments:

How much more loot do I need to entice you with :)


wjm comments:

Hi Kyle,
here it is,
i created a plugin, but its pretty much a class,
install it, activate it (read the usage instructions).
there are two versions, one that includes the visual/HTML buttons, and one that doesnt

I still need to work on some jquery code to set the same with and height for the html textarea as for the visual one.

here version 0.1 http://wordpress.pastebin.com/TwhbHeyh
here's version 0.1.1 (With the visual/html buttons) http://wordpress.pastebin.com/TY3wYfn0

i created this class specially for you as i had it inserted in the code of another proyect.

how much more?
it's up to your generosity.

let me know if it work, or it doesnt.

- wjm

NOTE: your custom fields need to have set the ID and be textareas i guess


wjm comments:

the above code works when name and id of the textarea are the same.


Kyle Jones comments:

hey there-
i haven't had anytime to check out your answer but I will here in a bit.
thanks,
~Kyle~


Kyle Jones comments:

@wjm

So your plugin is installed and activated and I'm using this as a metabox:
function ct_mb_editor2(){
global $post;
$custom = get_post_custom($post->ID);
$ct_mb_editor2 = $custom["ct_mb_editor2"][0];
//Load the rich text editor into the metabox
if ( class_exists( 'WjmTinymce' ) ) {
$richmetaboxes = new WjmTinymce();
$richmetaboxes->fields = array( 'ct_mb_editor2' );
$richmetaboxes->toggle_html_visual = true; // false if you dont want to show the HTML/VISUAL buttons
}
?>
<textarea name="ct_mb_editor2" id="ct_mb_editor2"></textarea>
<?php
}


The metabox is there and so is the textarea but no rich text editor. Ideas?


wjm comments:

can you upload to pastebin the output of your admin page.


wjm comments:

and place the WjmTinyMCE in your functions.php but outside any function.
that maybe the reason why its not working (the class is being called too late)


wjm comments:

that is:

function ct_mb_editor2(){
global $post;
$custom = get_post_custom($post->ID);
$ct_mb_editor2 = $custom["ct_mb_editor2"][0];
?>
<textarea name="ct_mb_editor2" id="ct_mb_editor2"></textarea>
<?php
}

//Load the rich text editor into the metabox
if ( class_exists( 'WjmTinymce' ) ) {
$richmetaboxes = new WjmTinymce();
$richmetaboxes->fields = array( 'ct_mb_editor2' );
$richmetaboxes->toggle_html_visual = true; // false if you dont want to show the HTML/VISUAL buttons
}


Kyle Jones comments:

Hey-

Here's the plugin I'm using to add the metabox. It's used in conjunction with your plugin enabled. Still, I just get a textarea.
[[LINK href="http://wordpress.pastebin.com/q287azVr"]]http://wordpress.pastebin.com/q287azVr[[/LINK]]

Here's the output of the admin:
[[LINK href="http://wordpress.pastebin.com/d27cKKZU"]]http://wordpress.pastebin.com/d27cKKZU[[/LINK]]

I'd love to get this to work. If you're willing to continue to work with me and help me understand I'll <em>definitely</em> up the reward here or just pay you directly.

Many thanks!
~Kyle~


Kyle Jones comments:

wjm-
well, I got it to work. it's a little rough around the edges with these noticeable issues:
1- It doesn't look like a regular metabox
2- It can't be relocated like a regular metabox unless in html mode

but, it is a working option so I'll award your the cash.

thanks for your assistance,
~kyle~