Published by Mijingo

tips icon image

EE Insider Tips
Sponsored by Mijingo's EE 2 Screencasts

ExpressionEngine mini-howtos created by the EE Insider community.

Careful when combining conditionals and backspace=“x”

User's avatar
  • Posted by Brent Cartier
  • June 23, 2009
  • 2 people have found this tip helpful.

I’ve run into this ‘gotcha’ a few times and have seen it frequently on the forums.

When using conditionals inside a weblog:entries loop, be careful that the backspace feature doesn’t clip the closing tag of your conditional. In this example you’ll end up with a broken or blank page depending where it occurs in the template:

{exp:weblog:entries weblog="products" backspace="1"}
   {if lang 
== "fr"}
       {title_fr}
,
   
{if:else}
       {title}
,
  
{/if}
{
/exp:weblog:entries} 

EE will trim the closing curly brace of

{/if} 

which of course breaks things. Make sure to arrange the comma (in this case) after the conditional like so:

{exp:weblog:entries weblog="products" backspace="1"}
   {if lang 
== "fr"}
       {title_fr}
   {if
:else}
       {title}
  {
/if}
  
,
{/exp:weblog:entries} 

Hope that prevents some heads banging against walls…

Add Your Comment?

You must have an EE Insider account to post comments on Insider Tips. It's fast, easy and hassle-free.

Sign up now (or login).

Search EE Insider Tips
Sponsored By