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.

Customising the CMS /

Adding a "Footer" tab on the top level


Go to End
Reply


12 Posts   3666 Views

Avatar
Carbon Crayon

Community Member, 598 Posts

24 January 2009 at 12:04pm

your welcome :)

Avatar
Tomae

Community Member, 14 Posts

25 January 2009 at 12:12am

hi ,
First of all , Thanxs aram , Ur tuts helped a lot....

I m new to silver stripe.........
i got a problem with my footer.... i wanted a static footer that means it should be editable at admin end and same for all pages. Once i change the content it shld get updated for all pages.
I made a page type called footer.php like you said . Here is my code...

<?php

class Footer extends Page {

static $db = array(
'FooterLink' => 'HTMLText',
);

static $has_many = array(

);

function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('FooterLink'), 'FooterLink');

$fields->removeFieldFromTab("Root.Content.Main","Content");
return $fields;
}

}

class Footer_Controller extends Page_Controller{

}

?>

and i put $FooterLink in page template "Page.ss " where i hav made my footer div. Now i placed the function which calls my "Footer.PHP" in Page type " Page.PHP ". Here is the code....

class Page_Controller extends ContentController {

public function GetFooter(){
return DataObject::get_one("Footer");
}    
}

my sidebar is working g8.....but I cant work out how to get the footer ....
tell me , WHts wrong with my code ??

Avatar
Carbon Crayon

Community Member, 598 Posts

25 January 2009 at 2:05am

Hi Tomae, welcome to Silverstripe :)

I think the problem is the way you are calling footer in your template. When you return a DataObject like a Page as you do in your GetFooter() function you can call it in two ways. first would be like this:

<% control GetFooter %>
$FooterLink
<% end_control %>

The second would be like this:

$GetFooter.FooterLink

At the moment you are just calling $FooterLink so SS will be looking in the current Page class for the field FooterLink, but you want to tell SS that it needs to look in the DataObject that is returned by the function GetFooter().

Avatar
Tomae

Community Member, 14 Posts

27 January 2009 at 6:47pm

cool.....it works......... thanx man.......

Go to Top