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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   1479 Views

Avatar
digibrains

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:
(templates)
Page.ss

(Layout)
Page.ss
HolderPage.ss

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

Thanks!
Chris

Avatar
Sticks

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 %>
  </ul>
<% end_if %>

Taken from Building a basic site.

Avatar
digibrains

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