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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Built in page controls

Go to End

3 Posts   1104 Views


Community Member, 130 Posts

23 January 2012 at 7:39am

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

My page structure is like this:


(Includes) <-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/
<% 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.



Community Member, 31 Posts

23 January 2012 at 10:55am

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.


Community Member, 130 Posts

24 January 2012 at 8:46am

Edited: 24/01/2012 8:46am

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 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!