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