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.

IF Statement Looping Indefinitely

December 06, 2012 9:03am

Subscribe [2]
  • #1 / Dec 06, 2012 9:03am

    Aerdan

    2 posts

    Hello,

    I’m trying to parse a URL and it has been looping indefinitely for me even when I’m at the root. Basically I want it to process this check if segment_2 exists and is not equal to history and there is no segment_3. Because of my use of preloads, I can’t nest the statements, but I’m not sure why this code isn’t working correct. Even when I’m at my root level with no segments, this statement still runs and causes the page to reload like crazy.

    {!-- Segment 2 is Top Level: Verifying Category Exists --}
    {if segment_2 !="" AND segment_2 !="history" AND segment_3 ==""}
        {exp:query
            sql="SELECT cat_id, cat_name
            FROM exp_categories
            WHERE cat_url_title = '{segment_2}'
            LIMIT 1"}
    
            {if no_results}
                {redirect="latest"}
            {/if}
    
            {snip-html-head}
            {preload_replace:content-url="news-category"}
        {/exp:query}
    {/if}
  • #2 / Dec 06, 2012 11:56am

    Kurt Deutscher

    827 posts

    Sounds to me as if the custom query is parsing before the conditional, so the page keeps hitting the redirect you have in there before it considers the simple conditionals.

    Hm… you know the use of the “AND” in that simple conditional may actually be turning it into what EE processes as an advanced conditional, and those process after other things on the page, and that might be it. Let me see if I can find an old post for you with some detail.

    Here it is: http://ellislab.com/forums/viewthread/161874/#778181

    Note the link at the bottom too with more discussion.

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

ExpressionEngine News!

#eecms, #events, #releases