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, biapar, Willr, Ingo, swaiba, simon_w

if clouse: sintax error


2 Posts   1046 Views


16 December 2009 at 4:27am (Last edited: 16 December 2009 5:52am), Community Member, 192 Posts


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?


16 December 2009 at 9:05am Forum Moderator, 5511 Posts

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 %>