[wp-hackers] Second editor instance
admin at laptoptips.ca
Thu Mar 20 09:41:58 GMT 2008
Alex Günsche wrote:
> I have the following problem:
> I'm writing a plugin for WP 2.5 that inserts a second editor on the page
> editing page, using the function the_editor(). The relevant code is:
> --- SNIP ---
> function spsi_editor()
> <div id="spsi_editorcontainer" class="postarea">
> <h3><?php _e('Secondary content', 'spsi'); ?></h3>
> <?php the_editor($mystuff, 'spsi_content', 'content', true, 3); ?>
> add_action('edit_page_form', 'spsi_editor');
> --- SNIP ---
> It looks ok at first sight, and it works ok when visual editing is
> disabled. But in WYSIWYG mode, there are problems: In the second editor,
> the iconbar is missing until "visual" is clicked. Then, the editor
> instances seem to interfer, both seem to be damaged (especially
> switching from visual to HTML mode), although basic WYSIWYG operations
> I wonder: are these bugs, have I done something wrong, or is it simply
> impossible to have two editor instances on one page?
> Tested with r7402 in FF 184.108.40.206/Linux.
I think if you call the_editor() more than once on the same page, it
will insert tags with the same IDs, so the js will get confused.
Perhaps append another textarea on the page and add a button to bind
TinyMCE to it too, or you can make it bind on page load. Then you will
have 2 editors that look the same, but save to 2 different textareas.
If you want them to be different, start the second one with another init
array. See the documentation here:
More information about the wp-hackers