GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.37k stars 4.05k forks source link

[QUESTION] Correct format for load template #2104

Closed georgikolev7 closed 5 years ago

georgikolev7 commented 5 years ago

Hey,

I'm searching for the right way of loading template, generated by GrapesJS, but nothing is loading.

Can someone please check, maybe format is not ok. https://api.myjson.com/bins/14o5yz

There is no error message, just empty editor.

Data is saved in the database with the following code

$params = file_get_contents('php://input');
$params = json_decode($params, true);

The type of the columns is TEXT.

This is my code

var builder = grapesjs.init({
        container : '#html-wrapper',
        plugins: ['gjs-preset-newsletter', 'gjs-plugin-ckeditor', 'img-link-plugin'],
        clearOnRender: true,
        assetManager: {
            upload: '/index.php?page=mod&mod=' + mod_param + '&action=ajax-upload-images',
            dropzone: true,
        },
        storageManager: {
            id: 'gjs-',
            type: 'remote',
            autoload: true,
            autosave: true,
            storeComponents: true,
            storeStyles: true,
            stepsBeforeSave: 1,
            contentTypeJson: true,
            urlStore: '/index.php?page=mod&mod=' + mod_param + '&action=ajax-save-campaign-template',
            urlLoad: '/index.php?page=mod&mod=' + mod_param + '&action=ajax-load-campaign-template&template_id=' + template.id,
            params: {
                template_id: template.id,
                template_name: template.name
            }
        }
    });
georgikolev7 commented 5 years ago

Issue was caused by invalid JSON data inside "gjs-components" on saving, which breaks the loading later.