HTMLEditorField on frontend


#1

Silverstripe Version: 4.3.2

Question:

I’m upgrading a SS3 site to SS4. This site has an area where non-CMS users can write descriptions in rich text.

I cannot find any information on how to get the HTMLEditorField to work on the front-end. Any advice?


#2

Give this a try:

These two will be needed in the controller for the page.

Requirements::javascript('silverstripe/admin:thirdparty/tinymce/tinymce.min.js');
Requirements::css('silverstripe/admin:client/dist/styles/editor.css');

You can add the fields to the form with a standard field method:
HTMLEditorField::create('Content')->setTitle('Content Editor Field'))

And you’ll need to add some JS to initialise the editor, eg:

tinymce.init({
        selector: 'textarea',
        skin: 'silverstripe',
        max_height: 250,
        menubar: false
});

#3

legend, works perfectly.

For future reference, you’ll likely want to disable the menu and status bars.

    <script type="text/javascript">
        tinyMCE.init({
            selector: 'textarea',
            skin: 'silverstripe',
            menubar: false,
            statusbar: false,
        });
    </script>

#4

How I enable image upload in the editor in the frontend?


#5

I think a lot of the popup buttons need the rest of the CMS to work properly.
The way I’ve gotten around it in the past is having separate UploadFields for images


#6

My requirement is to edit html content through frontend…images can be placed anywhere in the content…so I can’t have a seperate upload field…


#7

If are able to upload a image through upload field then should be a way to upload through content editor…