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.

Themes /

Discuss SilverStripe Themes.

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

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


Reply


5 Posts   4795 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, 101 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
banal

Community Member, 901 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!