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   3434 Views

Avatar
Hat-Rack

23 January 2009 at 12:37am Community Member, 12 Posts

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!

Avatar
SilverRay

23 January 2009 at 2:37am Community Member, 167 Posts

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

Avatar
Carbon Crayon

23 January 2009 at 2:53am Community Member, 598 Posts

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

Avatar
Hat-Rack

23 January 2009 at 3:02am Community Member, 12 Posts

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

Avatar
Hat-Rack

23 January 2009 at 3:45am Community Member, 12 Posts

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.

Avatar
SilverRay

23 January 2009 at 3:55am Community Member, 167 Posts

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?

Avatar
Carbon Crayon

23 January 2009 at 4:40am (Last edited: 23 January 2009 4:41am), Community Member, 598 Posts

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 :)

Avatar
Hat-Rack

24 January 2009 at 5:13am Community Member, 12 Posts

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

Go to Top