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.