Jump to:

23370 Posts in 18160 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » or clause

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

Page: 1 2
Go to End
Author Topic: 1601 Views
  • bebabeba
    Avatar
    Community Member
    192 Posts

    or clause Link to this post

    Hi!
    I wrote this

    <% if First_name or Last_name %>hello <% end_if %>

    but isn't correct..can you hel me to write in correct mode?

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: or clause Link to this post

    AFAIK there is no "OR" in the template syntax.. ;)

    You'll have to make do with IF constructs...

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: or clause Link to this post

    But I need an OR clause.
    If first_name OR last_name are present I print someting, else no.
    How can I solve this problem?

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: or clause Link to this post

    Well.. construct an or by using if / else ?

    It is not pretty, but it works.

    e.g
    if bla1
    if bla2
    else
    print something
    end_if
    end_if

    etc. etc.

  • cliersch
    Avatar
    Community Member
    75 Posts

    Re: or clause Link to this post

    Yes - but if only bla2 is true this will not work!

    You may build a php function to check your names.

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: or clause Link to this post

    Hence the " etc. etc." in my post.

    Of course , The cleaner way would be to add a method to your PHP class.

  • cliersch
    Avatar
    Community Member
    75 Posts

    Re: or clause Link to this post

    There was a discussion 2 years ago about the "Template page control with boolean operators" http://silverstripe.org/archive/show/77286#post77286 and http://groups.google.com/group/silverstripe-dev/browse_thread/thread/db752c5de80f3156

    I'm still missing the boolean functions inside the Template page control.

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: or clause Link to this post

    Actually you can use <% if First_name || Last_name %>.

    1601 Views
Page: 1 2
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.