This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

VektarDesign
VektarDesign

I have some tables in content files which the customer will be able to copy as a template when creating a new page.

As the content files are editable, they can be destroyed or changed but doesn't bode well if the next time they come to copy it for a new page and someone has messed up the table.

I only want them to be able to copy then paste into a new page then be able to edit it on the page, not in the content file.

Hope that makes sense, any help will be appreciated.

mjauvin
mjauvin

Yes:

\Event::listen('backend.form.extendFieldsBefore', function ($widget) {
    if (!$widget->getController() instanceof \RainLab\Pages\Controllers\Index) {
        return;
    }   
    if (!$widget->model instanceof \RainLab\Pages\Classes\Content) {
        return;
    }   

    $widget->secondaryTabs['fields']['markup']['readOnly'] = true;
}); 
mjauvin
mjauvin

At least this works for markdown content files... you can go from here.

mjauvin
mjauvin

This will work, preventing saving/deletion of the Content files from the Pages plugin side:

        \RainLab\Pages\Classes\Content::extend(function ($model) {
            $model->deleting(function () {
                // prevent anything from deleting
                return false;
            });
            $model->saving(function () {
                // prevent anything from saving
                return false;
            });
        });

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.