TinyMCE templates and contents

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
christ2000
User
Posts: 528

TinyMCE templates and contents

Post by christ2000 »

Hello i am working try to integrate tinymce templates and phpmaker, so i have this code on my edit page - client script

$(document).on("create.editor", function(e, args) {
    // Uncomment to view the arguments in the browser console
    // console.log(args);

    if (args && args.id == "x_Desired_Schedule_Notes") {
        // Modify the plugins, toolbar, and other settings for this editor
        args.settings.plugins += " template";
        args.settings.plugins += " lists checklist";
      //  args.settings.toolbar += " checklist";
        args.settings.toolbar += " template";
             

        // Define your template samples
        args.settings.templates = [
            {
                title: 'Select One',
                description: '',
                content: ''
            },
            {
                title: 'Admision Completed',
                description: 'This is email for Admision.',
                content: '<p>Insert your content here for Sample Template 1.</p>'
            },
            {
                title: 'Discharge Completed',
                description: 'This is email for client discharged.',
                content: '<h2>Sample Template 2</h2><p>Insert your content here for Sample Template 2.</p>'
            }
            // Add more templates as needed
        ];

        

    }
});

my question is if there any way to get values like NAME while i am on edit page and populate auto on my tinymce template when i load on the content editor? i try to use as {{{Name}}} but do not work

thanks


mobhar
User
Posts: 11807

Post by mobhar »

It won't work because the code with enclosed three curly braces is for Custom Template, while your code above for Startup Script.

You may try $("#x_Name").val() to get the current value.


christ2000
User
Posts: 528

Post by christ2000 »

Thanks for the help as you recomendation my code worked as:

 title: 'Admision Completed',
                description: 'This is email for Admision.',
                content: `<p>Hello ${$("#x_Name").val()} ${$("#x_LastName").val()}</p>`

christ2000
User
Posts: 528

Post by christ2000 »

Hello how to set content to tinymce editor? i as using

args.get("x_Desired_Schedule_Notes").setContent("<p>Hello world!</p>");

but do not work


christ2000
User
Posts: 528

Post by christ2000 »

Thanks this one work i left here for reference

// Set content for the editor
    args.settings.init_instance_callback = function (editor) {
        editor.setContent(`<p>Hello ${$("#x_Name").val()} ${$("#x_LastName").val()}</p>`);

    },

Post Reply