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.

Themes

Discuss SilverStripe Themes.

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

How to edit footer via cms...


Reply

5 Posts   2705 Views

Avatar
Webdoc

26 November 2009 at 5:40am Community Member, 332 Posts

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.

Avatar
Martijn

26 November 2009 at 6:07am Community Member, 271 Posts

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/

Avatar
Webdoc

26 November 2009 at 6:24am Community Member, 332 Posts

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

Avatar
Webdoc

26 November 2009 at 6:28am Community Member, 332 Posts

Hope u can help

Avatar
Martijn

26 November 2009 at 7:03am (Last edited: 26 November 2009 7:05am), Community Member, 271 Posts

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