Reputation: 72
I would like to be able to set custom values in the CMS, such as with the site name and tagline. I can't currently find any way of doing this other than on individual pages.
Upvotes: 1
Views: 158
Reputation: 5875
You can do so by extending SiteConfig
. Your Extension might look like this:
class CustomSiteConfig extends DataExtension
{
private static $db = array(
'CustomContent' => 'Varchar(255)'
);
public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.Main',
TextField::create('CustomContent', 'Custom content')
);
}
}
Then you need to apply the extension to SiteConfig
. Add the following to mysite/_config/config.yml
SiteConfig:
extensions:
- CustomSiteConfig
And that's it. Run dev/build
and your new field should be editable in the CMS as well as accessible in the Template using: $SiteConfig.CustomContent
Upvotes: 2