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.

parent_id always returning 0

August 16, 2011 10:32am

Subscribe [2]
  • #1 / Aug 16, 2011 10:32am

    Philip Zaengle

    293 posts

    I’m running EE 2.2.2 - I’m using the following code to output some rather basic XML.

    Problem is that {parent_id} variable is always returning the value 0. Even when the category has a parent category.

    {exp:channel:entries dynamic="no" channel="products" category_group="8"} 
        
    {/exp:channel:entries}

    When using the channel categories tag pair the categories are output with the correct parent_id.

    {exp:channel:categories channel="products" style="linear" dynamic="no" category_group="8"}
            {if parent_id == 0}<category>{/if}
            {if parent_id != 0}<sub_category>{/if}
                <id>{category_id}</id>
                {parent_id}</parent_id>
                <url_title>{category_url_title}</url_title>
                <name>{exp:xml_encode}{category_name}{/exp:xml_encode}</name>
            {if parent_id != 0}</sub_category>{/if}
            {if parent_id == 0}</category>{/if}
        {/exp:channel:categories}

    Suggestions as to why the {categories} variable pair wouldn’t have the correct value for {parent_id}?

    PS. there is no nesting going on.

  • #2 / Aug 16, 2011 8:39pm

    Dan Decker

    7338 posts

    Hi Philip,

    I’m sorry this is being an issue for you. I copied your template code directly and wasn’t able to replicate the problem. I got the following output:

    
       
          
       
          

    So your template code is technically valid.  Is there more to the template that you could share? There may be some clues in there. I ran this as html vs. XML

    Cheers,

  • #3 / Aug 17, 2011 3:42pm

    Philip Zaengle

    293 posts

    Nope, that’s pretty much it… I’ll continue testing.

  • #4 / Aug 19, 2011 1:14pm

    Kevin Smith

    4784 posts

    Hi Philip,

    Be on the lookout for an email from me. We’ll work with you to see what’s going on here.

  • #5 / Aug 23, 2011 12:36pm

    Kevin Smith

    4784 posts

    Hi Philip,

    Just checking it to see if you got the email that I sent you on Friday. Let us know when you’re ready to continue!

  • #6 / Aug 24, 2011 4:35pm

    Lisa Wess

    20502 posts

    Hi, Philip -

    Checking in again, we’re eager to help you out. =)

    Thanks!

  • #7 / Feb 06, 2012 6:38pm

    Chris Arnold

    201 posts

    EE 2.4—I’m seeing the same thing. Everything is outputting 0 for me. I’m attempting to only show the name of the sub category in the

    but if I try an {if parent_id != 0} it comes back blank. Sure enough a test shows everything is 0. Using GWcode Cats but that shouldn’t matter here. Disclosure: been having issues with the client’s host giving me permission to modify the standard EE file permissions from the install phase, so I’m not sure if something from that could be the issue, but figured I’d ask.
    {exp:gwcode_categories
     channel="education-topics"
     depth="1"
     show_empty="no"
     style="linear"
     orderby="cat_name"
     sort="asc"
     entry_count="yes"
     status="open"
     parse="inward"
    }
    
    <h5>{cat_name} Topics ({entry_count}) - Parent id: {parent_id}</h5>
    
    <p><div class="accordions"><br />
     <br />
     {exp:channel:entries channel="education-topics" category="{cat_id}"}<br />
     <!-- accordion --><br />
     <div class="accordion-wrap"><br />
      <div class="accordion-button"><br />
       <h3>{categories}{category_name}{/categories} - Parent id: {parent_id}</p>
    </h3>
    <p>  </div><br />
      <div class="accordion-content"><br />
       {exp:field_value entry_id="{entry_id}"}<br />
       {field_value_education-topics-content}<br />
       {/exp:field_value}<br />
      </div><br />
     </div><br />
     {/exp:channel:entries}</p>
    
    <p></div></p>
    
    <p>{/exp:gwcode_categories}

  • #8 / Feb 07, 2012 5:19pm

    Chris Arnold

    201 posts

    Turns out my issue was with a plugin conflict. The developer was great helping me identify that his also used parent_id and had me alter line 956 to the following:

    'parent_id' => $this->categories[$gw_i]['parent_id'],

    to…

    'cat_parent_id' => $this->categories[$gw_i]['parent_id'],

    Perhaps this will help someone avoid the issue down the line. Thanks!

  • #9 / Feb 09, 2012 5:12pm

    Dan Decker

    7338 posts

    Hey Chris,

    I’m glad the add-on developer was able to get you squared away!

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases