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


Reply

4 Posts   1106 Views

Avatar
DeklinKelly

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

I am creating a simple custom menu template named TopMenu.ss 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 %>

Avatar
Hamish

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

Avatar
DeklinKelly

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!

Avatar
DeklinKelly

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