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.

Subcategory isn't visible when using show parameter

October 25, 2012 4:42am

Subscribe [2]
  • #1 / Oct 25, 2012 4:42am

    Est Digital

    62 posts

    Subcategory isn’t visible when using show parameter

    I think it would be best to put the these/not-these check on the cat_array rather then the result_array but i can imagine this would be bad performance-wise.

    I tested this problem in EE 2.4.0 but 2.5.3 doesnt have any changes on this part.

    Cats:

    Category 1 (id 5)
    Subcategory 1 (id 7, parentid 5)

    Template:

    {exp:channel:categories channel="discussies" style="linear" show="{segment_3}"}{category_name}{/exp:channel:categories}

    Results:

    when segment_3 = 5, category 1 is shown which is correct.
    when segment_3 = 7, nothing is shown which is incorrect.


    In /system/expressionengine/modules/channel/mod.channel.php
    rule 5109 (EE 2.4.0)
    rule 5257 (EE 2.5.3)

    foreach($query->result_array() as $row)
       {
        if (isset($not_these) && in_array($row['cat_id'], $not_these))
        {
         continue;
        }
        elseif(isset($these) && ! in_array($row['cat_id'], $these))
        {
         continue;
        }
    
        $this->temp_array[$row['cat_id']]  = array($row['cat_id'], $row['parent_id'], '1', $row['cat_name'], $row['cat_description'], $row['cat_image'], $row['cat_url_title']);
    
        foreach ($row as $key => $val)
        {
         if (strpos($key, 'field') !== FALSE)
         {
          $this->temp_array[$row['cat_id']][$key] = $val;
         }
        }
       }
    
       foreach($this->temp_array as $key => $val)
       {
        if (0 == $val[1])
        {
         $this->cat_array[] = $val;
         $this->process_subcategories($key);
        }
       }

    What happens here is that the result array is being filtered by the these/not-these parameter and after that the cats who are parents are being checked if they have childs.

    If show = 7, only 7 will be in the result array. so theres no way 5 will be checked for childen and the result is empty.

  • #2 / Oct 25, 2012 1:50pm

    Shane Eckert

    7174 posts

    Hey Kees Internet,

    Right, this is expected behavior.

    You need to have the parent and the child in order to see the child. It sounds like you are only returning the child in the case where it’s not working, but the parent when it does. Which makes sense.

    Little more here.

    Does that make sense?

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases