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.

General Questions

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

If page type


4 Posts   1106 Views


23 June 2009 at 8:53am Community Member, 197 Posts

I am creating a simple custom menu template named and I want to set the css class to "selected" if the page type is "fooBar"

Obviously, this does not work:

<% if Page_Type== "red" %>class="selected"<% else %>class="notSelected"<% end_if %>


23 June 2009 at 10:00am (Last edited: 23 June 2009 10:01am), Community Member, 712 Posts

<% If Class = MyPageClass %>class="foo"<% else %>class="bar"<% end_if %>


23 June 2009 at 9:14pm Community Member, 197 Posts

Hamish, your idea does not work. It gives a parsing error! So I modified it but my code still does not work.

<% if class == "IndexPage" %>class="foo"<% else %>class="bar"<% end_if %>

Any more ideas? Thanks!


23 June 2009 at 10:44pm Community Member, 197 Posts

Here is the correct code:

<% if ClassName = MyPageClass %>class="foo"<% else %>class="bar"<% end_if %>