Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am New in customizing CKEditor. I want to bind templates from database in Templates popup.

I have added two testing templates statically in default.js file shown as below :

JavaScript
/*
Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
*/
CKEDITOR.addTemplates("default",
{
    imagesPath: CKEDITOR.getUrl(CKEDITOR.plugins.getPath("templates") + "templates/images/"),
    templates: [
                {
                    title: "Image and Title",
                    image: "template1.gif",
                    description: "One main image with a title and text that surround the image.",
                    html: '<h3><img src=" " alt="" style="margin-right: 10px" height="100" width="100" align="left" />Type the title here</h3><p>Type the text here</p>'
                },
                {
                    title: "Strange Template",
                    image: "template2.gif",
                    description: "A template that defines two colums, each one with a title, and some text.",
                    html: '<table cellspacing="0" cellpadding="0" style="width:100%" border="0"><tr><td style="width:50%"><h3>Title 1</h3></td><td></td><td style="width:50%"><h3>Title 2</h3></td></tr><tr><td>Text 1</td><td></td><td>Text 2</td></tr></table><p>More text goes here.</p>'
                },
                {
                    title: "Text and Table",
                    image: "template3.gif",
                    description: "A title with some text and a table.",
                    html: '<div style="width: 80%"><h3>Title goes here</h3><table style="width:150px;float: right" cellspacing="0" cellpadding="0" border="1"><caption style="border:solid 1px black">Table title</caption><tr><td> </td><td> </td><td> </td></tr><tr><td> </td><td> </td><td> </td></tr><tr><td> </td><td> </td><td> </td></tr></table><p>Type the text here</p></div>'
                },
                {
                    title: 'My Template 1',
                    image: "template1.gif",
                    description: 'Description of My Template 1.',
                    html: '<h2>Template 1</h2><p>Type your text here.</p><p style="color:red;">This is demo of custom template.</p>'
                },
                {
                    title: 'My Template 2',
                    image: "template2.gif",
                    html: '<h3>Template 2</h3><p>Type your text here.</p>'
                }
              ]
});


Now I want to get these templates from database.

Please help me to overcome from this query...

Thanks...
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900