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:

Template Questions /

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

Checking parent value from within a <% control %>

Go to End

2 Posts   1916 Views


Community Member, 21 Posts

8 July 2010 at 5:53am

I have a sidebar with highlight items grouped into different sections...

- Project Highlight 1
- Project Highlight 2

- Publication Highlight 1
- Publication Highlight 2

On one particular type of page I would like to include some additional text below some of the highlight sections. However, I can't figure out how to get the <% if %> to check the proper variable from within the control block.

<% control Highlights %>
<% control Items %>
<% end_control %>

<% if page is of a particular type %>
<% if Section = Projects %>
<p>Extra project text</p>
<% end_if %>
<% if Section = Publications %>
<p>Extra publications text %>
<% end_if %>
<% end_if %>
<% end_control>

So what I want is the <% if page is of a particular type %> to check the ClassName value for the page...which I understand in theory is considered a parent to the control block...but how do I write that within the <% if %>. I've tried <% if ClassName = ProjectPage %>, <% if Top.ClassName = ProjectPage %>, and <%if Parent.ClassName = ProjectPage %> all to no avail.



Community Member, 33 Posts

8 July 2010 at 6:29am

You could create an for the particular page type where you want the additional information to appear and for all other page types include your default sidebar sub-template.