Jump to:

1379 Posts in 490 Topics by 520 members

Themes

SilverStripe Forums » Themes » How to edit footer via cms...

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 2665 Views
  • Webdoc
    Avatar
    Community Member
    332 Posts

    How to edit footer via cms... Link to this post

    Is there anyway possible to make the footer text editable via cms so that ot is in top menu near to security and others.

    and how to display it in footer.ss file.

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: How to edit footer via cms... Link to this post

    You could create a seperate DataObject and use ModelAdmin to admin the DataObject, or use this approach:

    http://www.ssbits.com/create-a-static-sidebar/

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: How to edit footer via cms... Link to this post

    Can u give me a sample code because it not sidebar but footer.

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: How to edit footer via cms... Link to this post

    Hope u can help

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: How to edit footer via cms... Link to this post

    You could use the same code, but display it in the footer instead of the sidebar.

    Or create a PageType like GlobalBlockPage.

    And add in the static $db array ("Footer" => "Text", "OtherStaticText" => "Text" ); //etc

    To ensure that the pagetype never show up in the menu add () to class GlobalBlockPage :

    function onBeforeWrite () {
    if($this->ID){
    $this->record['ShowInMenus'] = 0;
    }
    parent::onBeforeWrite ();
    }

    To ensure you only have One GlobalBLockPage type add:

    function canCreate() {
          if(DataObject::get_one('GlobalBlockPage')) {
             return false;
          } else {
             return true;
          }
       }

    In Page_Controller (not BlobalBlokPage) you do something like:

    getFooter(){
    return DataObject::get_one("GlobalBlockPage")->FooterText;
    }

    or

    getOtherStaticText(){
    return DataObject::get_one("GlobalBlockPage")->OtherStaticText;
    }

    Or call the whole object once and call getYourFunction.FooterText in the templates...

    This should get you started.
    Of Course you still can create DataObject and admin it with ModelAdmin and call that Object from Page to show it on the frontend:

    http://doc.silverstripe.org/doku.php?id=modeladmin

    2665 Views
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.