Jump to:

23480 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » if clouse: sintax error

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
Go to End
Author Topic: 1036 Views
  • bebabeba
    Community Member
    192 Posts

    if clouse: sintax error Link to this post


    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?

  • Willr
    Forum Moderator
    5502 Posts

    Re: if clouse: sintax error Link to this post

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

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