Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Separate footer menu

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 4447 Views
  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Separate footer menu Link to this post

    Hi all, I have a top level navigation menu (2 levels) and I also want to have a separate footer menu (2 levels)

    my current menu structure looks something like this:

    I can get the top level menu working OK by just excluding the footer in the template:

    <% control Menu(1) %>
    <% if URLSegment != footer %>

    <li class="$LinkingMode"><a href="$Link" >$MenuTitle</a>
    <% if Children %>
    <ul>
    <% control Children %>
    <li class="$LinkOrSection"><a href="$Link" >$MenuTitle</a></li>
    <% end_control %>
    </ul>
    <% end_if %>
    </li>

    <% end_if %>
    <% end_control %>

    but I cant work out how to get the footer output...any ideas would be appreciated

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Separate footer menu Link to this post

    Hey Galilee,

    In order to do something like that, you could use this in your template:

    <% control ChildrenOf(footer) %>
       Insert your normal navigation code here
    <% end_control %>

    The ChildrenOf but lets you get the children of any page using the URL segment.

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: Separate footer menu Link to this post

    Awesome! works like a charm:)

  • S0crates9
    Avatar
    27 Posts

    Re: Separate footer menu Link to this post

    Hi Guys!

    Funny thing is that I am still a bit confused about how the navigation is controlled on silverstripe implementations. I've got a similar structure to what was listed on this thread but the advice given didn't work, and I've also tried other methods to get the specific breakout of navigation to work - to no avail.

    Take a look at the attached file to see the admin layout. I've set up the navigation to only show top-level items on the homepage and as you go into the second level pages, then opens up the children (third-level) pages.

    Now what the pain point seems to be is that I want to put the sitemap page into the footer, not to display it on the nav menu...

    Anyone know how I can do this given the page setup I've got?

    I would appreciate any info you could afford, been driven a bit nuts trying to get this to work.

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Separate footer menu Link to this post

    Is the sitemap.xml file your own creation/page? I'm just confused it is showing in the sitetree or am wondering if you did some modification to it.

    By default, it is created so you don't have to do anything. domain.com/sitemap.xml Assuming you're not using a really old version of SS.

    Anyway, check out this link for another way of making a special menu.

    http://doc.silverstripe.com/doku.php?id=recipes:page_selection_for_special_menu

    *Edit* Just noticed the reason the other code doesn't work, is that sitemap doesn't have any children so it won't display. What you can do is untick the option to "show in menus" in the behaviour tab on the page type. Then in your footer, do something like

    <% control Page(sitemap) %><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a><% end_control %>

  • S0crates9
    Avatar
    27 Posts

    Re: Separate footer menu Link to this post

    I am using silverstripe 2.2.3...

    Thanks for the response. Sitemap.xml is indeed somethign I added in which generates a standard XML file for SE use.

    The code/suggestion you amended seems to also not yield the result I'd imagine...
    I still see nothing show up in the footer code.

    And as for the thread you referred me to, for some reason I get this error:
    "Error The website server has not been able to respond to your request."
    And it seems to happen when I put in the topTabbers function into Page.php.

    Just to provide a bit more insight into what I have working, here is the nav code:

    <ul id="Navigation">
    <% control Menu(1) %>
    <li>
    <a class="$LinkingMode topsec" href="$Link" title="Go to the $Title.XML page">$MenuTitle<span></span></a>
    <% if Children %>
    <% if LinkOrSection = section %>
    <ul id="Sub-Menu">
    <% control Children %>
    <li class="$LinkingMode<% if FirstLast %> $FirstLast<% end_if %>">
    <% if LinkingMode = current %>
    <a class="items" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
    <% else %>
    <a class="item" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
    <% end_if %>
    </li>
    <% if LinkOrSection = section %>
    <ul id="Sub-Menu">
    <% control Children %>
    <li class="$LinkingMode<% if FirstLast %> $FirstLast<% end_if %>">
    <% if LinkingMode = current %>
    <a class="items subsec" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
    <% else %>
    <a class="item subsec" href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
    <% end_if %>
    </li>
    <% end_control %>
    </ul>
    <% end_if %>

    <% end_control %>
    </ul>
    <% end_if %>
    <% end_if %>
    </li>
    <% end_control %>
    </ul>

    I was thinking that because the files are in a tree format, their hierarchical level would be also used in silverstripe, but I was never able to get beyond menu(1) or Level(1).

    #### UPDATE ####
    I changed the topTabber function to SiTabber and the error went away, however the pages selected to show up in the special menu still do not appear. I also tried ticking the "show in Menus" checkbox to test the variable, but it still didn't appear in the footer.

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Separate footer menu Link to this post

    Regarding your sitemap.xml, is it any different then the one SS generates? Just wondering if you're making a page that is not needed, as I have mentioned SS generates a sitemapl.xml file for SEO purposes. You don't have to do anything or create your own. If you were to remove/delete/unpublish your page sitemap.xml, you can still access a file domain.com/sitemap.xml which is the default one.

    I also noticed my code above is wrong, it should be <% control Page(Site-Map) %>. I read your image wrong. You basically change "Site-Map" to whatever the page name/url is. Lower/Uppercase does matter.

    As for the example code for the different menu, not too sure unless I saw some code. I've seen many people use it as is and it works.

  • S0crates9
    Avatar
    27 Posts

    Re: Separate footer menu Link to this post

    Yes, LeeUmm, the sitemap.xml was one I created since the sitemap.xml that silverstripe was supposed to generate for some reason, did not. And this was across 5 different silverstripe sites I am working with right now.

    As for the footer code, I tried changing it and the page still doesn't show up after a flush.

    Anything else I can take a look at to figure out what is going wrong?

    Thanks again for your assistance!

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