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.

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

if clouse: sintax error

Go to End

2 Posts   1354 Views


Community Member, 193 Posts

16 December 2009 at 4:27am

Edited: 16/12/2009 5:52am


In my .ss page I wrote this line of code. My proble is apply an if clouse to every div.

For example :

if $Name != '' then show div else go on.

Can you hel me write this in a correct way please?My <% if $Nome !='' %> is not correct

<% if Conn %>
<ul id="product">
<% control Conn %>
<% if $Nome !='' %><div class="nome_query_2"> $Nome </div><% end_if %>

<% if $Type !='' %><div class="nome_query_2"> $Type </div> <% end_if %>
<% end_control %>
<% end_if %>

And if I need an or clouse?for example <% if $Nome !='' or $Type !='' %> what is the correct syntax?


Forum Moderator, 5523 Posts

16 December 2009 at 9:05am

You cannot use != '' in the template parser. In your case you are just checking that Name exists, which you should just be able to do <% if Name %>