I have the following code within a template
<h1>{segment_2_category_name}</h1>
{exp:channel:categories show="{segment_2_category_id}" style="linear" parent_only="no"}
{category_description}
{if content-image}
{exp:ce_img:pair src="{content-image}" max_width="328"}
<img src="{made}" alt="{segment_2_category_name}">
{/exp:ce_img:pair}
{/if}
{/exp:channel:categories}
This displays the category description, category image etc. and it works fine for top level categories. However, it doesn't display anything but the title for sub-categories.
I have checked whether {segment_2_category_id} is being parsed by placing it inside the channel:categories tag and it outputs the ID as expected.
Does anyone have a clue why this might not be working?
UPDATE: Removing the ce_img tags makes no difference.
You can see the pages concerned here;
http://www.gillardcutting.com/applications/food-extrusion (top level cat)
http://www.gillardcutting.com/applications/dog-chews-dental-sticks (sub cat)
UPDATE
I've created a test template, cut back to the bare bones, in order to analyse the queries being run. The following query is executed;
SELECT LOWER(cat_url_title) AS cat_url_title, `cat_id`, `parent_id`, `group_id`, `cat_name`, `cat_description`, `cat_image`
FROM (`exp_categories`)
WHERE `site_id` = '1'
AND LOWER(cat_url_title) IN ('applications', 'test', 'dog-chews-dental-sticks')
AND `group_id` IN ('3', '2')
If I run this query directly on the database then I get back the expected category information.
It's as if, for some reason, the stuff between the opening and closing exp:channel:categories tag pair just isn't being parsed IF I'm dealing with a sub-category.
This site is running on EE 2.4 (so next step is to try an update) and is using Structure as well as Low Seg2Cat but I don't think either of these is the issue as everything is working as it should except for this particular issue (and even then only with subcategories).
UPDATE
It appears that I must specify the parent category ID in order to get any child category information to display. This is despite my earlier finding regarding the query that is being executed.
Even adding parent_only="no" does not allow me to display child category data without also having the parent category included.
Is this an intentional feature or just some peculiarity/bug relating to the version of EE that this site is running?
Guess what? Another UPDATE - Workaround fix
I've figured out a workaround based on my findings, it's not perfect by any means and will break quite easily but will work OK in this particular instance.
Basically;
I include the seg2cat tag to get the current category's parent id and include this in the show parameter, this ensures we can display the child data.
To ONLY show the child data I then use a conditional to check the category being output in the loop against the seg2cat category id and only show it if it's the child category.
{exp:channel:categories show="{segment_2_category_parent_id}|{segment_2_category_id}" parent_only="no" style="linear"}
{if '{category_id}' == '{segment_2_category_id}'}
{category_description}
{if content-image}
{exp:ce_img:pair src="{content-image}" max_width="328"}
<img src="{made}" alt="{segment_2_category_name}">
{/exp:ce_img:pair}
{/if}
{/if}
{/exp:channel:categories}
If anyone can come up with a better way to do this I'd love to know!