ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Conditional limit?

March 25, 2011 2:29pm

Subscribe [3]
  • #1 / Mar 25, 2011 2:29pm

    James Smith

    259 posts

    This is going to sound a bit crazy, but is there some kind of limit imposed on the number of conditionals that a template can use?

    I’ve run into a situation where my page white-screens after adding a simple conditional, regardless of whether it’s true or false and regardless of where it’s placed in the template. If I remove any other conditional in the template I can then add another one… if I remove two I can add another two elsewhere…

    Very strange…?

  • #2 / Mar 26, 2011 6:46pm

    Greg Salt

    3988 posts

    Hi James,

    How many conditionals are we talking about here? Have you confirmed that exact conditional will work on its own? Please switch on error reporting so that you can see the exact error message that is causing the white screen.

    Cheers

    Greg

  • #3 / Mar 28, 2011 7:01pm

    James Smith

    259 posts

    I’m still not sure what happened - the conditionals I was testing with were literally {if 1 == 1}{/if} just to make sure they weren’t the problem, but I narrowed it down to a conditional which was in the format:

    {if segment_4 == "results"}{if "{exp:my_plugin:correct_answer question='{question}'}"}Congratulations!{/if}{/if}

    After triple checking that my plugin was successfully returning TRUE or FALSE, and many other things, I finally found that separating out the two conditionals with newlines solved the problem:

    {if segment_4 == "results"}
        {if "{exp:my_plugin:correct_answer question='{question}'}"}Congratulations!{/if}
    {/if}

    I’d still love to know why this solves it though so I can avoid the problem in future!

    PS… it might also be relevant to mention that this code is contained within a P&T List loop which is also contained within a P&T Matrix loop.

  • #4 / Mar 29, 2011 2:48pm

    Brandon Jones

    5500 posts

    Hi James,

    First make sure that Debug Preference is set to “1”. If that doesn’t work, try testing those simple conditionals outside of any loops and without the plugin, as I suspect something else is in play.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases