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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

or clause


Go to End


11 Posts   3248 Views

Avatar
bebabeba

Community Member, 193 Posts

26 January 2010 at 10:00pm

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?

Avatar
Fuzz10

Community Member, 791 Posts

26 January 2010 at 11:54pm

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

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

Avatar
bebabeba

Community Member, 193 Posts

27 January 2010 at 12:12am

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?

Avatar
Fuzz10

Community Member, 791 Posts

27 January 2010 at 12:30am

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.

Avatar
cliersch

Community Member, 75 Posts

27 January 2010 at 12:42am

Edited: 27/01/2010 12:43am

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

You may build a php function to check your names.

Avatar
Fuzz10

Community Member, 791 Posts

27 January 2010 at 12:47am

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

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

Avatar
cliersch

Community Member, 75 Posts

27 January 2010 at 1:06am

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.

Avatar
ajshort

Community Member, 244 Posts

27 January 2010 at 7:23am

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

Go to Top