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

Page class conditional in template include


Go to End


2 Posts   2101 Views

Avatar
DeklinKelly

Community Member, 197 Posts

6 August 2010 at 7:22am

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

Avatar
swaiba

Forum Moderator, 1899 Posts

6 August 2010 at 8:06am

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