1

Topic: template plugin and template_external_list_url

The template plugin documentation states

Example of an external list

This is the contents your backend page should return if you specify a URL using the template_external_list_url option. A simple array containing each template to present. This URL can be a backend page, for example a PHP file.

var tinyMCETemplateList = [
        // Name, URL, Description
        ["Simple snippet", "templates/snippet1.htm", "Simple HTML snippet."],
        ["Layout", "templates/layout1.htm", "HTML Layout."]
];

I used this feature quite extensively in the 3.x branch but even though it is referred to in the 4.x documentation I do not see it supported in the code anywhere.  I'm assuming this has been deprecated and the documentation just hasn't been updated?

2

Re: template plugin and template_external_list_url

I figured out a quick workaround for anybody wanting to use this type of feature.  Convert your old editor setting directive to the new directive and then use the object you had originally created rather than the url.  Just add the url to your page that loads the editor and your variable becomes global.  One caveat, you need to convert your old JSON array to use the new field names (title, url, description) rather than a 0-based array.

//template_external_list_url : "/templates/mytemplatelist"
templates : tinyMCETemplateList

3

Re: template plugin and template_external_list_url

Fixed now:
https://github.com/tinymce/tinymce/comm … 45b7f1158f

Best regards,
Spocke - Main developer of TinyMCE

4

Re: template plugin and template_external_list_url

Thanks ... again!  When I get a moment I'll update the wiki docs to show the object structure in the code snippet.

5

Re: template plugin and template_external_list_url

Humm, please,
I 've got the same trouble !
All is ok in V3, but with V4, i can't use the template_external_list_url (Message "No template defined").

I tried to put :

templates : "tinyMCETemplateList"

I got a new box (Title "Template" , with "Insert template" but list is empty),
I want doc please to help me to understand what should i write to use a description file of tempates files.

Last edited by alain01 (2013-10-19 02:08:43)

XOOPS Team

6

Re: template plugin and template_external_list_url

In V4,
The template_templates woks,
but not the template_external_list_url.

I dont want to hard code list of templates in the setting.php, i just want to put the template_external_list_url.

Please some Help ?
Is these a bug ? (The template_external_list_url V3 works)

XOOPS Team

7

Re: template plugin and template_external_list_url

We have fixed this in the GitHub repo. Will be released in 4.0.9. If templates is a string it's treated as an URL.

Best regards,
Spocke - Main developer of TinyMCE

8

Re: template plugin and template_external_list_url

Hello,

I have a bug using a URL with template:

templates : '/ajax.php?action=list&tab=snippet',

Result :

var tinyMCETemplateList = [
["alerts", "/admin/template/snippet/alerts.html"],
["badges", "/admin/template/snippet/badges.html"],
["button", "/admin/template/snippet/button.html"],
["progress-bars", "/admin/template/snippet/progress-bars.html"],
["thumbnails", "/admin/template/snippet/thumbnails.html"]
];

But with template plugin : Message "No template defined"

I use tinymce 4.0.9

Last edited by gtraxx (2013-10-27 17:16:00)

Main developer of Magix CMS AND magix cjQuery

9

Re: template plugin and template_external_list_url

I've just tried the v 4.0.9 and i got the same trouble :

ok with

templates: [
        {title: 'Some title 1', description: 'Some desc 1', content: 'My content'},
        {title: 'Cooking template', description: 'Use this template to build a cooking page', url: '/test-tinymce/gabarits/cooking-template.html'}
    ],

but failed with :

template_external_list_url:"/test-tinymce/gabarits/liste-templates.js",

"no templates defined"

In my /test-tinymce/gabarits/liste-templates.js :

// Liste templates files for TinyMCE

var tinyMCETemplateList = [ 
// Nom, URL, Description
    ["Cooking template", "/test-tinymce/gabarits/cooking-template.html", "Use this template to build a cooking page"]
];

XOOPS Team

10

Re: template plugin and template_external_list_url

Use:
http://www.tinymce.com/wiki.php/Configuration:templates

See example

Best regards,
Spocke - Main developer of TinyMCE

11

Re: template plugin and template_external_list_url

Ok, thanks to rewrite the doc, but 1 thing miss : An example of the /dir/templates.php content.
Cause i tried :

var tinyMCETemplateList = [ 
// Nom, URL, Description
    ["Cooking template", "/test-tinymce/gabarits/cooking-template.html", "Use this template to build a cooking page"]
];

=> No templates defined

i tried

templates: [
        {title: 'Some title 1', description: 'Some desc 1', content: 'My content'},
        {title: 'Some title 2', description: 'Some desc 2', url: 'development.html'}
    ];

=> No templates defined

Could you write an example, please ?

Last edited by alain01 (2013-10-28 16:09:00)

XOOPS Team

12

Re: template plugin and template_external_list_url

It should be the same json structure. Will add docs on that.

Best regards,
Spocke - Main developer of TinyMCE

13

Re: template plugin and template_external_list_url

Yessssss, i tried many many solutions and i found (couldnt wait for the updating docs)

Here an example :

// Liste templates files for TinyMCE
// title: 'xxx', description: 'yyy', content: 'zzz'} 

    templates = [ 
        {title: 'template1', description: 'Some desc 1', content: 'My content'}, 
        {title: 'Cooking template', description: 'Use this template to build a cooking page', url: '/test-tinymce/gabarits/cooking-template.html'} 
    ]

All is ok now !!!

(that was "templates = [" and not "templates : [")

Last edited by alain01 (2013-10-28 17:09:25)

XOOPS Team

14

Re: template plugin and template_external_list_url

Thanks alain01 big_smile

PS : I changed the documentation page with an example.

http://www.tinymce.com/wiki.php/Configuration:templates

Aurélien

Last edited by gtraxx (2013-12-09 15:24:26)

Main developer of Magix CMS AND magix cjQuery