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.

Nested query breaks page

October 28, 2010 10:45am

Subscribe [3]
  • #1 / Oct 28, 2010 10:45am

    Chris Williams

    102 posts

    I’m trying to pull the results of child categories when looking at the parent category page.

    {exp:query sql="SELECT cat_id, cat_name, parent_id FROM exp_categories WHERE cat_url_title = '{segment_2}'"}
        <h1>{cat_name}</h1>
        
        {if {parent_id} != 0}
        <ul class="category">
            {embed="blog/inc_category" cat_id="{cat_id}"}
        </ul>
        {if:else}
            {exp:query sql="SELECT cat_id FROM exp_categories WHERE parent_id = '{cat_id}'"}
                This breaks.
            {/exp:query}
        {/if}
    {/exp:query}

    But I get this returned

    Parse error: syntax error, unexpected T_ENDIF in .../library/expressionengine/libraries/Functions.php(640) : eval()‘d code on line 86

    I even tried hardcoding cat_id to an existing value with same result.

    Any ideas?

  • #2 / Oct 29, 2010 1:11am

    the3mus1can

    426 posts

    Try this:

    {if "{parent_id}" != "0"}
  • #3 / Oct 29, 2010 5:22am

    denza

    13 posts

    Chris, I’ve used activerecord plugin for nested query http://devot-ee.com/add-ons/activerecord/

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

ExpressionEngine News!

#eecms, #events, #releases