Jump to:

5449 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: 3133 Views
  • Hat-Rack
    Avatar
    Community Member
    12 Posts

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

    I would like to add a tab alongside "Content, To do, Behavior, Reports, Security" that reads "Footer" and then 5 sub tabs that contain the information for each column of my footer.

    I've nailed adding second level tabs to existing top level tabs, but how would I add another top level tab to the Database?

    Thanks!

  • SilverRay
    Avatar
    Community Member
    167 Posts

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

    In your template.php:

    $fields->addFieldToTab( 'Root.WhateverTab', arguments here );

    See http://doc.silverstripe.com/doku.php?id=getcmsfields&s=addfieldtotab for more info.

    HTH

  • Aram
    Avatar
    Community Member
    598 Posts

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

    Hi Har-rack

    If you want to have multiple tabs within a new root tab you need to first create a new tabset like this:

    $fields->addFieldToTab('Root', new TabSet('TopTab'));

    then you can add as many new sub tabs as you like:

    $fields->addFieldToTab('Root.TopTab.SubTab', new TextField('FieldName');

    etc.....

  • Hat-Rack
    Avatar
    Community Member
    12 Posts

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

    It works great! Thanks - you're making this learning curve easy!

  • Hat-Rack
    Avatar
    Community Member
    12 Posts

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

    One other question - how do I make those fields I added "HomePage" template accessible to other templates on the site?

    $fields->addFieldToTab('Root.TopTab.SubTab', new TextField('FieldName');

    In the code above I would like, for example "Fieldname" to be accessible globally from the DB on every page so I can insert the one footer across many pages.

  • SilverRay
    Avatar
    Community Member
    167 Posts

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

    Well, if you would not add them to your home page template, but to the Page.php code, they extend to whatever page that extends from Page.php (inheritance). But then, these fields show up on every template (in the CMS) which means that whatever you enter in those fields is unique for that particular instance. Did you mean that you want to have fields that are truly global, in other words you edit them in one place but they show up on every page?

  • Aram
    Avatar
    Community Member
    598 Posts

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

    ok so you basically want a footer on your site which is editable in the admin right?

    So what you want to do is create a 'FooterPage' page type which will then hold all you footer variables in the same way that you would create a static sidebar. This thread shows you how to do that: http://www.silverstripe.org/customising-the-cms/show/252007

    You really want to have one place to edit your footer rather than having the fields on every page. Then you can just have a function GetFooter() in your Page_controller and return the FooterPage type so that you can use it in the templates

    If you need any more help just ask

  • Hat-Rack
    Avatar
    Community Member
    12 Posts

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

    Took a little while for me to nut it out, but now it's working! thanks once again.

    3133 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.