Hello,
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:
tinymce-templates/code/tinymceTemplates.php:
<?php
class tinymceTemplates extends LeftAndMainExtension{
function init() {
parent::init();
//tinymce plugins
HtmlEditorConfig::get('cms')->enablePlugins('template');
HtmlEditorConfig::get('cms')->insertButtonsAfter('tablecontrols','template');
HtmlEditorConfig::get('cms')->setOption('valid_elements','*- ');
HtmlEditorConfig::get('cms')->setOption('extended_valid_elements','*
- ');
HtmlEditorConfig::get('cms')->setOptions(array('template_templates' => array(
array(
'title'=>'Two columns','src'=>'$BaseURL/tinymceTemplates/templates/columns-2.htm','description'=>'A two column layout'
)
)));
}
}
tinymce-templates/templates/columns-2.htm:
<div class="row">
<div class="2-col">column one</div>
<div class="2-col">column two</div>
</div>
mysite/_config.php:
LeftAndMain::add_extension('LeftAndMain','tinymceTemplates');
Regards