Jump to:

23555 Posts in 19382 Topics by 2892 members

General Questions

SilverStripe Forums » General Questions » Built in page controls

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: 639 Views
  • prawnstar
    Community Member
    116 Posts

    Built in page controls Link to this post

    I have a question regarding the syntax of $ClassName page controls.

    My page structure is like this:


    Sidebar.ss <-this is where my page navigation is located. This template is included on both Layouts

    The "HolderPage," unlike a regular "Page," has children. When a visitor is on the HolderPage I want to display navigation for all children. This is easy.

    In my templates/Includes/sidebar.ss:
    <% if $ClassName=HolderPage %> ...navigation for child pages... <% end_if %>

    Whenever a visitor is on a HolderPage they see the navigation for the child pages.

    However, I want the navigation to be displayed when a user is also on a child page of the HolderPage, as well. I want something like this:

    <% if $ClassName=HolderPage || $Parent.ClassName=HolderPage %>

    But that doesn't seem to work, nor any variation that I can come up with. Can someone tell me if there is syntax to do this. Or do I have to make a completely separate HolderPage template with a custom sidebar for just that page? That seems like a long-form way of doing this.


  • Sticks
    Community Member
    29 Posts

    Re: Built in page controls Link to this post

    The menu(2) control sounds like it would work for you.

    <% if Menu(2) %>
    <ul id="Menu2">
    <% control Menu(2) %>
    <li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></li>
    <% end_control %>
    <% end_if %>

    Taken from Building a basic site.

  • prawnstar
    Community Member
    116 Posts

    Re: Built in page controls Link to this post

    Hi, Sticks,
    I was hoping to be more specific than just using Menu(2). My intention was to make more than one type of holder page, but use the same sidebar.ss for all holder pages and sub pages, and not show links on some of those pages.

    It's looking like my best bet is to use the Menu(2) option in conjunction with 'ShowInMenus' => false for some of these pages.

    Thanks for your reply!

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.