Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Making SiteConfig versioned


Go to End


3 Posts   1972 Views

Avatar
justin456

Community Member, 9 Posts

7 December 2012 at 8:57pm

Edited: 08/12/2012 1:05pm

I asked about this on IRC. I finally succeeded in customizing my SiteConfig in SilverStripe 3.0.2, and I am trying to make it versioned as well. I have the following lines in mysite/_config.php:


Object::add_extension('SiteConfig', 'Versioned("Stage","Live")');
Object::add_extension('SiteConfig','CustomSiteConfig');

My database now has the following tables:
SiteConfig, SiteConfig_CreateTopLevelGroups, SiteConfig_EditorGroups, SiteConfig_Live, SiteConfig_ViewerGroups, and SiteConfig_versions

The SiteConfig_versions table indeed has a couple of old versions of my SiteConfig. However, only the "Save" button appears in the UI, and I cannot save a draft, and there is no preview option to view the home page with the new siteconfig before I save it... Does anyone have suggestions?

EDIT: It looks like I need to write the function "updateCMSActions()" in my CustomSiteConfig extension to specify these actions.

EDIT #2: but all these actions are hard-coded in getCMSActions() in cms/code/model/SiteTree.php, so I need to rewrite as much of that functionality as I want from scratch, since SiteConfig is not part of SiteTree, and in particular, it should not be possible to delete the SiteConfig from the site.

Avatar
Willr

Forum Moderator, 5523 Posts

8 December 2012 at 4:35pm

Thanks for your work on this Justin! I would think that SiteConfig should be versioned out of the box so perhaps submit your ideas and work (once you have it working) as a pull request. If it's not something everyone else is interested it, would be a handy module!

Avatar
justin456

Community Member, 9 Posts

9 December 2012 at 11:11pm

Edited: 09/12/2012 11:13pm

Ok, I made a "Save & Publish" button appear in the SiteConfig (in addition to the "Save" button---which actually only saves a draft, contrary to my earlier post) by declaring the following function in my CustomSiteConfig.php

public function updateCMSActions(FieldList $actions) {
                $actions->push( FormAction::create(
                        'publish', _t('CMSMain.BUTTONSAVEPUBLISH', 'Save & Publish') )
                        ->addExtraClass('ss-ui-action-constructive')
                        ->setAttribute('data-icon', 'accept')
                );
        }

So I need to figure out how to make a button like this actually do something in SilverStripe...because now clicking that button generates a "not found" error, because there's apparently no code to handle such an action at present.