Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » SS3 tinymce templates help

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 660 Views
  • Harley
    Community Member
    153 Posts

    SS3 tinymce templates help Link to this post


    I'm currently trying to create a tinymce 'templates' module to allow html templates and snippets in your content.

    I refer to this article from 2010 http://internetstate.info/2010/12/07/tinymce-templates-in-silverstripe-htmleditorfield-and-simpletinymceeditor-dataobject-manager/

    I have the template button working fine, but as it retrieves the html file it is inserting my page content and not the html I've selected.

    I'm running out of ideas here but it would be nice to finish this off.

    Here is my code:



    class tinymceTemplates extends LeftAndMainExtension{

    function init() {

       //tinymce plugins   

    • ');
    • ');
         HtmlEditorConfig::get('cms')->setOptions(array('template_templates' => array(
            'title'=>'Two columns','src'=>'$BaseURL/tinymceTemplates/templates/columns-2.htm','description'=>'A two column layout'


    <div class="row">
       <div class="2-col">column one</div>
       <div class="2-col">column two</div>




  • Optic Blaze
    Community Member
    162 Posts

    Re: SS3 tinymce templates help Link to this post

    Hi there,

    There is a easier way to do this.

    1) Insert the following code into you _config.php file:


    // Enable template plugin in the WYSIWYG editor//
    HtmlEditorConfig::get('cms')->insertButtonsAfter('tablecontrols', 'template');

    //Specify location of your snippets//
    array('title'=>'3 Columns','src'=>'mysite/templates/3col.html','description'=>'3 Column template'),
    array('title'=>'2 Columns','src'=>'mysite/templates/2col.html','description'=>'2 Columns template'),
    array('title'=>'1 Column','src'=>'mysite/templates/1col.html','description'=>'1 column template'),

    2) Then under the mysite folder create a folder called templates.
    3) In the templates folder create your snippet html files...in this example they should be called 3col.html, 2col.html, 1col.html
    4) Run a dev build and refresh the cms
    5) In the CMS you should now have a new button (see screen shot) when you click it, it will give you a drop down menu of your snippets that you can insert anywhere in the document

    Attached Files
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.