Jump to:

520 Posts in 248 Topics by 263 members

Content Editor Discussions

SilverStripe Forums » Content Editor Discussions » Code snippets using syntaxhl TinyMCE plugin

Forum for content editors and CMS users.

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

Page: 1
Go to End
Author Topic: 2167 Views
  • oniroi
    Community Member
    2 Posts

    Code snippets using syntaxhl TinyMCE plugin Link to this post


    I would like to insert code snippets (e.g., Java snippets in a programming tutorial) on a SilverStripe 2.4.0 CMS --preferably without having to edit a page's HTML manually. The syntaxhl TinyMCE plugin (http://github.com/RichGuk/syntaxhl) seemed an ideal solution.

    I tried installing the plugin as follows:
    - downloaded the plugin code into site/cms/javascript/tinymce_syntaxhl
    - edited site/cms/_config.php such that the plugin is enabled and its button is installed:
    -- added HtmlEditorConfig::get('cms')->enablePlugins(array('syntaxhl' => '../../../cms/javascript/tinymce_syntaxhl/editor_plugin_src.js'));
    -- added HtmlEditorConfig::get('cms')->insertButtonsAfter ('formatselect', 'syntaxhl');
    -- added textarea[cols|rows|disabled|name|readonly|class] to extended_valid_elements

    This does result in an extra button being shown in the editor, but the associated popup is very rudimentary. The labels of the insert and cancel buttons, for instance, are #{insert} and #{cancel}. The same goes for all other form elements (e.g. {#syntaxhl_dlg.highlight_options}).
    Worse, the #{insert} button has no effect (popup does not close, nothing is inserted).

    I'm guessing the problem is related to the way I installed the plugin. Any help is appreciated as I'm a complete SilverStripe newbie (until now, the default installation suited my needs perfectly).

    Thanks in advance.

  • oniroi
    Community Member
    2 Posts

    Re: Code snippets using syntaxhl TinyMCE plugin Link to this post

    Moving the syntaxhl files to site/sapphire/thirdparty/tinymce/plugins/syntaxhl and subsequently enabling it through HtmlEditorConfig::get('cms')->enablePlugins('syntaxhl'); instead worked like a charm.

    My apologies for the unnecessary posting!

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.