0

I am having this problem with TinyMCE and i cant seem to find a solution. I tried everything suggested on google, and for most people it works the way as i use it. But for me it seems it doesn't or maybe it just works this way.

I use CodeIgniter 3 to handle most of the php. I have a webpage where i can edit the content of a webpage. So when i start typing and stuff, its nicely formatted in the TinyMCE editor. And when i save it, it is correctly saved. No problems at all.

But when i try to reload the content and put it in the TinyMCE editor it just displays the HTML tags, it doesn't format it at all. Like an Anchor tag, its just displayed as the plain text not as formatted HTML.

How i load the data in the text area from the controller:

$data['content'] = array(
            'id' => 'content',
            'name' => 'content',
            'value' => set_value('pageContent', $data['page']['content']),
            'class' => 'form-control'
        );

And how i output the textarea:

<?php echo form_textarea($content); ?>

Javascript code to initialize TinyMCE:

tinymce.init({
    setup: function (editor) {
        editor.on('LoadContent', function (e) {
            console.log('LoadContent event', e);
        });
    },
    selector: "#tekst",
    plugins: "image link",
    element_format: "html",
    theme: "modern",
    content_css: "<?php echo base_url('/assets/hu_css/styles.css') ?>",
    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
</script>

The content is loaded right, but not formatted. How do i solve this? Using TinyMCE configurations?

I hope someone can help/point me to the right answer!

Fjarlaegur
  • 1,395
  • 1
  • 14
  • 33

2 Answers2

0

You can try this. Previously i also encounter a problem on my tinymce. initialize tinymce with content

Community
  • 1
  • 1
  • I tried this, but instead of 'custom' i used '' The problem is, the content is so long the browser makes it multiline. Making the first line end in . Which gives me the "Uncaught SyntaxError: Unexpected token ILLEGAL" error. Oh by the way, the next line starts with

    . Does the browser do this because of the tags? Should i output it in another way?

    – Fjarlaegur Sep 26 '15 at 17:47
0

Just use <textarea name="content" id="content"><?php echo $content;?></textarea> instead of <?php echo form_textarea($content); ?>

Mebron
  • 1