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

if clouse: sintax error


Go to End
Reply


2 Posts   1209 Views

Avatar
bebabeba

Community Member, 193 Posts

16 December 2009 at 4:27am

Edited: 16/12/2009 5:52am

Hi!

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 %>
<li>
<% if $Nome !='' %><div class="nome_query_2"> $Nome </div><% end_if %>

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

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

Avatar
Willr

Forum Moderator, 5517 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 %>