Jump to:

23370 Posts in 18160 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » Page class conditional in template include

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: 1121 Views
  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Page class conditional in template include Link to this post

    In my template Includes folder, I have a file named "Header.ss"

    It is included like this:

    <% include Header %>

    I want to put a line in Header.ss that ONLY is displayed on pages with the page class of Foobar.

    This does NOT work:

    <% if Foobar %><h1>The Page Type is Foobar</h1><% end_if %>

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Page class conditional in template include Link to this post

    How about...

    <% if ClassName = Foobar %><h1>The Page Type is Foobar</h1><% end_if %>

    ... i think you need to use the db field in your if statement.

    Barry

    1121 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.