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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Adding a "Footer" tab on the top level


Go to End


12 Posts   7284 Views

Avatar
Hat-Rack

Community Member, 12 Posts

23 January 2009 at 12:37am

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

Community Member, 167 Posts

23 January 2009 at 2:37am

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

Community Member, 598 Posts

23 January 2009 at 2:53am

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

Community Member, 12 Posts

23 January 2009 at 3:02am

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

Avatar
Hat-Rack

Community Member, 12 Posts

23 January 2009 at 3:45am

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

Community Member, 167 Posts

23 January 2009 at 3:55am

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

Community Member, 598 Posts

23 January 2009 at 4:40am

Edited: 23/01/2009 4:41am

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

Community Member, 12 Posts

24 January 2009 at 5:13am

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

Go to Top