Jump to:

1382 Posts in 491 Topics by 521 members

Themes

SilverStripe Forums » Themes » if ($Title=="My Home"){...}

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 4556 Views
  • liyen
    Avatar
    Community Member
    1 Post

    if ($Title=="My Home"){...} Link to this post

    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!

  • patjnr
    Avatar
    Community Member
    101 Posts

    Re: if ($Title=="My Home"){...} Link to this post

    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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: if ($Title=="My Home"){...} Link to this post

    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

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: if ($Title=="My Home"){...} Link to this post

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

  • theo_
    Avatar
    Community Member
    1 Post

    Re: if ($Title=="My Home"){...} Link to this post

    Hi all!

    How to check this condition:

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

    Thanks!

    4556 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.