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

Multiple if statements in template

Go to End

2 Posts   1665 Views


Community Member, 197 Posts

2 December 2010 at 2:36pm

My template code gives an error. The problem is that I have multiple conditionals in the template.

        <% if Row3Heading || Row3Image || Row3Content || Row3LinkText %>
        <div class="bottomColumn">
        <% if Row3Heading %>
        <% end_if %>

        <% if Row3Image %>
          <p class="shadow"><% if Row3LinkURL %><a href="$Row3LinkURL.ATT"><% end_if %><img src="<% control Row3Image %>$SetWidth(250).Link<% end_control %>" alt="" title="" /><% if Row3LinkURL %></a><% end_if %></p>
        <% end_if %>

        <% if Row3Content %>
        <p class="text">$Row3Content.Parse(NiceXHTML)</p>
        <% end_if %>

        <% if Row3LinkURL && Row3LinkText %>
          <h2><a href="$Row3LinkURL.ATT">$Row3LinkText.Parse(NiceXHTML)</a></h2>
        <% end_if %>
        <% end_if %>

How can I use more than one set of || in the template?


Forum Moderator, 5523 Posts

2 December 2010 at 3:34pm

Template engine doesn't support that level of checking. You'll have to write that logic in your PHP code

function ShowBottomColumn() {
return ($this->Row3Heading || $this->Row3Image || $this->Row3Content || $this->Row3LinkText);

Then just use <% if ShowBottomColumn %>