Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Making SiteConfig versioned

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

Page: 1
Go to End
Author Topic: 576 Views
  • justin456
    Community Member
    9 Posts

    Making SiteConfig versioned Link to this post

    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")');

    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.

  • Willr
    Forum Moderator
    5497 Posts

    Re: Making SiteConfig versioned Link to this post

    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!

  • justin456
    Community Member
    9 Posts

    Re: Making SiteConfig versioned Link to this post

    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') )
    ->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.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.