Jump to:

1347 Posts in 439 Topics by 514 members

Themes

SilverStripe Forums » Themes » Changing Menu Context

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 752 Views
  • elgordo
    Avatar
    Community Member
    69 Posts

    Changing Menu Context Link to this post

    I've come across a situation in a current project where it would be useful to change the context of the menu that is showing on the left hand side (LHS). By this I mean at certain points in the site where the menu is missing I would like to substitute it with the menu from another part of the site.

    The structure I have used it to have the children of the root form a top level menu and the top of the page, and their children a drop down menu. When a top level item is chosen the menu that is shown on the LHS is the children of that item [ in SS templating terms, Level(2) ].

    There are 2 situations I have run into where there is no menu
    1) Where only the top level menu item exists with no children
    i) Search - I can get around this by providing perhaps suggested searches in the menu or advanced search
    ii) Contact Us - This is in the top level as a requirement

    2) When showing images for the image gallery with javascript turned off.

    The latter is more important. I followed this tutorial, http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/ , and successfully have the image gallery module showing gallery and images for non JS compliance (ie no fancy lightbox popup). The menu works in the cases of Albums inside an ImageGalleryPage (a DataObject with a Page as a parent) but not in the case of an image (effectively a DataObject with a parent DataObject). I can only assume that as the parent Album does not extend Page (and thus SiteTree) it has no place in the site hierarchy.

    What I would like to do is this: "In the case of showing an image I would like to populate the menu for the parent album"

    Is there a way of doing in a way to reuse the existing menu mechanism, ie have Level(1), Level(2) etc be populated by the parent and not the currently selected image? I realize I could re-implement the menu in this special case but it seems like a lot of overhead, so some pointers forward would be appreciated

    Regards

    Gordon

  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Re: Changing Menu Context Link to this post

    I don't know if you figured this out yet but you can use <% if Level(2) %><% else %><% control Parent %><% end_control %><% end_if %>

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