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

If page type


Go to End


4 Posts   2588 Views

Avatar
DeklinKelly

Community Member, 197 Posts

23 June 2009 at 8:53am

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

Community Member, 712 Posts

23 June 2009 at 10:00am

Edited: 23/06/2009 10:01am

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

Avatar
DeklinKelly

Community Member, 197 Posts

23 June 2009 at 9:14pm

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

Community Member, 197 Posts

23 June 2009 at 10:44pm

Here is the correct code:

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