Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » If page type

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

Page: 1
Go to End
Author Topic: 1096 Views
  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    If page type Link to this post

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

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: If page type Link to this post

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

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: If page type Link to this post

    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!

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: If page type Link to this post

    Here is the correct code:

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

    1096 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.