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

What type of page am I?


Go to End


5 Posts   880 Views

Avatar
sebastiankozub

Community Member, 59 Posts

28 October 2010 at 7:31am

Hi,

Is there a way to check in Page.ss template what page is displayed? or what type of page is displayed, for example HomePage etc.

I'm looking for somethink like <% if Homepage %>

I don't want to change whole template system for one little change on HomePage.
Because this change is in header so I have to do it in main - Page.ss template.

Thanks

Avatar
lerni

Community Member, 81 Posts

28 October 2010 at 8:24am

hi

<% if ClassName == HomePage %> $ClassName <% end_if %>

luk

Avatar
bummzack

Community Member, 904 Posts

28 October 2010 at 10:46am

The equality operator in templates is just =, not ==. Therefore it should be:

<% if ClassName = HomePage %> $ClassName <% end_if %>

Avatar
Ryan M.

Community Member, 309 Posts

28 October 2010 at 11:57am

You can also use this if you're trying to target a particular page:

<% if URLSegment = page-url %>do something here...<% else %>or something else here...<% end_if %>

Avatar
sebastiankozub

Community Member, 59 Posts

30 October 2010 at 5:58am

Thanks for every replay, it looks works fine :)