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

raz14769
raz14769

Hi im new to this CMS. My pages need a title and a subtitle. Title i can set in the backend. But is it possible to add a extra input for pages called "subtitle" and store this information?

uXMs
uXMs

Add this to extend your plugin:

public function boot()
{
    Event::listen('backend.form.extendFields', function ($widget) {
        if (
            !$widget->getController() instanceof \Cms\Controllers\Index ||
            !$widget->model instanceof \Cms\Classes\Page
        ) {
            return;
        }

        $widget->addFields([
            'settings[subtitle]' => [
                'label' => 'Subtitle'
            ]
        ]);
    });
}

and use this twig syntax:

{{ this.page.subtitle }}

1-2 of 2

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