TinyMCE/HtmlEditorConfig: enablePlugins('template') not working ("No templates defined.')

Silverstripe Version:4.4

Question:
I’m trying to enable the template plugin for TinyMCE as it was described here:
https://www.silverstripe.org/community/forums/customising-the-cms/show/23046
The icon shows up, but i cannot get the created template

app/_config.php:

HtmlEditorConfig::get('cms')->enablePlugins('template');
HtmlEditorConfig::get('cms')->insertButtonsAfter('underline', 'template');
//Specify location of your snippets//
HtmlEditorConfig::get('cms')->setOptions(array('template_templates'=>array(
	array('title'=>'Name','src'=>'public/htmlsnippets/name.html','Name'=>'Name')
)));

Did anyone get this running?

Thanks in advance and best regards
boo

Hi. I push that up again. Maybe someone has an idea or solution for it? I would be very thankful.

thanks in advance and regards
boo

I haven’t used the Template plugin before, but I would guess that the template_templates.src property needs to be relative to the web root. So if your templates are in a public/htmlsnippets/ directory, you would pass e.g. 'src'=>'/htmlsnippets/name.html'.

Also judging by the docs for TinyMCE4, I’m not sure your config is valid. See TinyMCE | Template Plugin

Apologies for an absolute necropost however i had the need to implement this from a wordpress transfer to silverstripe. To get TinyMCE’s Templates/Snippet plugin working the config SetOptions should just be ‘templates’ not ‘template_templates’ for TinyMCE4.

HtmlEditorConfig::get('cms')->setOptions(array('templates'=>array(
	array('title'=>'Name','src'=>'public/htmlsnippets/name.html','Name'=>'Name')
)));

or just reference a PHP file rather than an array and store your array as json
HtmlEditorConfig::get('cms')->setOption('templates', 'tinytemplates.php');

with the following json

[
  {"title": "HTMLSnippet", "description": "HTML Snippet", "content": "<p>My HTML content</p>"},
  {"title": "HTMLTemplate", "description": "HTML Template from File", "url": "MyHTMLTemplate.html"}
]