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

Testing if on homepage


Reply


4 Posts   2053 Views

Avatar
losqualo

Community Member, 17 Posts

2 September 2010 at 10:04pm

Hi,

Possibly dumb question, but is there a means of testing for whether the current page is the homepage? I'd like to modify the behaviour of an include for when on the homepage, and don't really want to create a homepage specific include to do the job. Something like

<% if home %>
...
<% endif %>

Been through the docs, but see nothing obvious... but then I'm still acclimatising to silverstripe

Thanks in advance

Rob

Avatar
Martijn

Community Member, 271 Posts

2 September 2010 at 10:44pm

<% if URLSegment = 'home' %>

<% end_if %>

Avatar
losqualo

Community Member, 17 Posts

4 September 2010 at 2:54am

Thanks... However

<% if URLSegment = 'home' %>

<% end_if %>

generates a syntax error due to an unexpected '}', which is odd.

If I remove the quotes from 'home', then all works OK.

Cheers

Rob

Avatar
Martijn

Community Member, 271 Posts

4 September 2010 at 9:23am

Yes, sorry. My bad :)