Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Content Editor Discussions /

Forum for content editors and CMS users.

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

Code snippets using syntaxhl TinyMCE plugin


Go to End


2 Posts   4054 Views

Avatar
oniroi

Community Member, 2 Posts

7 July 2010 at 1:54am

Hi,

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.

Avatar
oniroi

Community Member, 2 Posts

7 July 2010 at 2:19am

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!