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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Add Top and Footer Navigation Menu


Reply


4 Posts   1823 Views

Avatar
spankmaster79

Community Member, 46 Posts

10 November 2010 at 12:24am

Hi,

I would like to have a footer and top navigation that is independent from the normal navigation menu.

I came up with a solution that is not really satisfying. My solution was to add a page, that is not in the menu and then add pages under it like this:

- TopNavigation (not in menu)
- Page 1
- Page 2

and then in the template:

<% control ChildrenOf(TopNav) %>
<li><a href="$Link" title="$Title">$MenuTitle</a></li>
<% end_control %>

But clicking on the link it has /topNav/ or /FooterNav always in it. I would like to only have /page1 /page2

What would be the correct solution to this? I think more people have more than one menu on their page...

Kind regards
Spanky

Avatar
sebastiankozub

Community Member, 40 Posts

10 November 2010 at 2:14am

you can use recipe here http://doc.silverstripe.org/recipes:page_selection_for_special_menu

you just create checkbox in admin panel that will decide if the page will be shown in menu (you should create two)

static $db = array(
"ShowInTabMenu" => "Boolean"
);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Behaviour", new CheckboxField("ShowInTabMenu", "Show special menu "));
return $fields;
}

then in page controller create functions, you shuold create two function e.g. headerMenu() nad footerMenu()

function topTabbers() {
$whereStatement = "ShowInTabMenu = 1 AND ShowInMenus = 1";
return DataObject::get("Page", $whereStatement);
}

then jus use $headerMenu or $footerMenu Page.ss

Avatar
spankmaster79

Community Member, 46 Posts

10 November 2010 at 4:21am

Hi,

that worked and was excactly what I wanted ;-)

Thanx

Avatar
elgordo

Community Member, 70 Posts

17 November 2012 at 3:07am

hi

I've created a module to deal with footer links, though I guess there is no reason why it could not be applied to header links also. Details can be found at http://weboftalent.asia/blog/links-module/

Regards

Gordon [Anderson]