tags:

views:

648

answers:

2

i have setup tinymce in a webpage for users to generate html data that i am putting on my website.

the issue is that i have existing html pages that i want to use as a starter.

I want to have the first time they go to tinymce page, it prepopulates the textarea with the wysiwyg view of the html file on my local disk.

is there any way to take an html stream and have it prepopulate a textarea so it shows the wysiwyg instead of the html. i need to ensure that this conversion doesn't lose any formatting.

+1  A: 

When set up to load onto an existing textarea, TinyMCE will display the HTML already loaded into that textarea. Load the HTML into the textarea on the server side. For example (pseudocode):

echo "<textarea class=\"text\">"
echo html_encode( html_stream )
echo "</textarea>"

And the JavsaScript:

<script type="text/javascript">
tinyMCE.init({
    mode : "specific_textareas",
    editor_selector : "text",
});
</script>
Josh
Ok after posting this I just saw your changes and I lack confidence that I am answering your question... sorry! Point me in the right direction...
Josh
+1  A: 

I have built a custom CMS with TinyMCE which does essentially what you describe. I have found when I prepopulate the textarea that TinyMCE displays as WYSIWYG by default.

The HTML can be read from file on disk, or stored elsewhere.

Have you actually tried yet?

nathan
btw, if you'd like to bind TinyMCE to a specific textarea (as opposed to initializing ALL textareas) the JavaScript call is: tinyMCE.execCommand("mceAddControl", true, target_id);...where target_id is the id of the target textarea tag.
nathan