5098 Posts in 1518 Topics by 1115 members
| Go to End | ||
| Author | Topic: | 2715 Views |
-
Re: Adding a "Footer" tab on the top level

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 ?? -
Re: Adding a "Footer" tab on the top level

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().
-
Re: Adding a "Footer" tab on the top level

27 January 2009 at 6:47pm
cool.....it works......... thanx man.......
| 2715 Views | ||
| Go to Top |

