Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Add Top and Footer Navigation Menu

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

Page: 1
Go to End
Author Topic: 1689 Views
  • spankmaster79
    Avatar
    Community Member
    46 Posts

    Add Top and Footer Navigation Menu Link to this post

    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

  • sebastiankozub
    Avatar
    Community Member
    40 Posts

    Re: Add Top and Footer Navigation Menu Link to this post

    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

  • spankmaster79
    Avatar
    Community Member
    46 Posts

    Re: Add Top and Footer Navigation Menu Link to this post

    Hi,

    that worked and was excactly what I wanted ;-)

    Thanx

  • elgordo
    Avatar
    Community Member
    70 Posts

    Re: Add Top and Footer Navigation Menu Link to this post

    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]

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