I have an instance of TinyMCE running on a page that enables me to edit existing posts. I query the db, and populate the variable $content
with the stored text. I then have the following HTML:
<label for="content">Content:</label>
<textarea name="content" class="post-content" rows="<?php echo $settings_rows; ?>" ><?php echo $content; ?></textarea>
TinyMCE is displaying as an editor, no problem, but is not displaying the text stored in $content
. There are no outlying <p>
tags, and the $content
variable is being populated (I echo'd it outside of the textarea to be sure, and Firebug shows the hidden textarea also being populated).
The editor init is as follows:
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "advimage",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,|,image,hr,removeformat,visualaid,charmap,code",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_resizing : true,
editor_selector : "post-content"
});
Can anyone advise me why this isn't working? I've used it on other pages, using this exact system, without a hitch.
EDIT
As a P.S. the relevant CSS is as follows:
.post-content {
padding: 3px 10px;
width: 90%;
}
Try the following. Give your textarea the id "editor1", use mode: "exact",
instead of mode: "textareas",
and initialize your editor the following way (keep the tinymce init where it is for now, but before the following lines)
$(document).ready(function() {
tinyMCE.execCommand('mceAddControl', false, 'editor1');
}