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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Themes /

Discuss SilverStripe Themes.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

if ($Title=="My Home"){...}


Go to End


5 Posts   8237 Views

Avatar
liyen

Community Member, 1 Post

26 February 2010 at 12:24am

DEar all, I'm very new to silverstripe...
I would like to find out what's the way to write the condition like this?

if ($Title=="My Home"){...}

Hope you can share...

Thanks!

Avatar
patjnr

Community Member, 102 Posts

26 February 2010 at 7:36am

Edited: 26/02/2010 7:37am

Hi

welcome to SS the greatest CMS ever developed by humankind.

here is how you do it.

<% if Title == "My Home" %>
     yo stuff here
<% else %>
     second option
<% end_if %>

hope it will help

P

Avatar
bummzack

Community Member, 904 Posts

26 February 2010 at 10:24am

To check for equality, use = instead of ==. AFAIK spaces won't work either, so you better check the URLSegment or similar.
Something like this:

<% if URLSegment = my-url-segment %>

<% end_if %>

If you really want to check the title, create a custom function for it on your controller

Avatar
ttyl

Community Member, 114 Posts

23 September 2010 at 3:42am

just want to +1 that URLSegment is the way to go with these.

Avatar
theo_

Community Member, 1 Post

7 April 2011 at 2:43am

Hi all!

How to check this condition:

if ($Photo.Width > 100){...}

Thanks!