Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Adding a "Footer" tab on the top level

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

Page: 1 2
Go to End
Author Topic: 3139 Views
  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Adding a "Footer" tab on the top level Link to this post

    your welcome

  • Tomae
    Avatar
    Community Member
    14 Posts

    Re: Adding a "Footer" tab on the top level Link to this post

    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 ??

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Adding a "Footer" tab on the top level Link to this post

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

  • Tomae
    Avatar
    Community Member
    14 Posts

    Re: Adding a "Footer" tab on the top level Link to this post

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

    3139 Views
Page: 1 2
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.