Sorry for the delayed response. Located in Houston, so we havent had any power.
I am obviously missing something. When I use more than one OR statement nothing shows up; no matter the condition. Using the code provided, I changed the “some_tier2_segment” to an actual segment name. If I use only one condition, that page will work then the others will fail with the following errors:
Notice: Undefined variable: parent_cat_description in /home/[sitepath]/plugins/pi.child_categories.php on line 474 and line 475. followed by what appears to be a full list of all of the sites categories.
Also, one other thing that might be a problem once this works is that I am having to hard code the segment names in the condition. This will prevent the site from being dynamic as I would hope it to be.
Curious, is the Categories in EE fairly new? Seems that what I am trying to do should be pretty straight forward.
Thanks again,
If segment conditional does not work inside parameter, then try to wrap with that conditional entire tag.
if you do not want to hardcode possible segment values, then at first check for existence of certain segment.
The code would be approximately as follows:
{if segment_3!=""}
{exp:category_id category_group="8" category_url_title="{segment_3}" parse="inward"}
{exp:child_categories parent="{category_id}" site="2" show_empty="yes" entries_limit="5" parse="inward"}
{child_category_start}
<a href="http://{homepage}/Services/{child_category_url_title}/">{child_category_name}</a>
{child_category_end}
{/exp:child_categories}
{/exp:category_id}
{/if}
{if segment_3==""}
{exp:category_id category_group="8" category_url_title="{segment_2}" parse="inward"}
{exp:child_categories parent="{category_id}" site="2" show_empty="yes" entries_limit="5" parse="inward"}
{child_category_start}
<a href="http://{homepage}/Services/{child_category_url_title}/">{child_category_name}</a>
{child_category_end}
{/exp:child_categories}
{/exp:category_id}
{/if}
Thanks! That worked for the tier 3 items. Now trying to get the tier 2 items to display. I would have thought using Segment_1 would do the trick, but that seems to cause errors. Hmm…
Just to backtrack a bit. The navigation is 3 tier. Tier 1 is along the top, Tier 2 is in a <div> on the upper right and Tier 3 is also in a <div> on the lower right side. Tier 1 is static. Currently Tier 2 is also static with the dynamic Tier 3 using the code above. Again thanks for that! Now if I can get Tier 2 to be dynamic, I will be set.
About Us (Tier 1/Template - static/top nav) - HQ Location (Tier 2/Weblog - dynamic/right top nav) - Contact Information (Tier 2/Weblog - dynamic/right top nav) - - Email (Tier 3/Weblog - dynamic/right bottom nav) - - Phone (Tier 3/Weblog - dynamic/right bottom nav) - - Mailing (Tier 3/Weblog - dynamic/right bottom nav) - Business Principles (Tier 2/Weblog - dynamic/right top nav) - Some other category (Tier 2/Weblog - dynamic/right top nav) Services (Tier 1/Template - static/top nav)
Using this code, I got it to display the parent category, but it only shows the first (HQ Location) in the list. There are three.
{exp:category_id category_group="8" category_url_title="{segment_2}” parse=”inward”}
{exp:child_categories parent="{category_id}” site=”2” show_empty=”no” entries_limit=”5” parse=”inward”}
{parent_category_start} {parent_category_name} {parent_category_end}
{/exp:child_categories}
{/exp:category_id}
Thanks!
If I understood you correctly, you have 3 levels of categories
Category level 1 Category level 2, that is child category of the category level 1 Category level 2, that is child category of the category level 2
and you would like by setting category id of category level 1 as the value of “parent” parameter of exp:child_categories tag to display categories of all three levels.
Unfortunately this is impossible because Child categories plugin can display only two levels of categories.
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" entries_limit="5"}
{parent_category_start}
<a href="http://{homepage}/{thisblog}/category/{parent_category_url_title}/">{parent_category_name} - Index</a>
{parent_category_end}
{child_category_start}
- <b><a href="http://{homepage}/{thisblog}/category/{child_category_url_title}/">{child_category_name}</a></b> ({entries_total})
{child_category_end}
{/exp:child_categories}
Thank you SO much for this plugin. I am HOPING there is a way to display not just the current child categories but the categories one level below the current. For example:
http://www.thrivingnow.com/for/Health/category/eft-resources-more
Any way to get that level of recursion?
Rick
Hi Rick,
I am HOPING there is a way to display not just the current child categories but the categories one level below the current.
Of course, there is. You can use exp://weblog:categories tag or exp://weblog:category_archive tag.
Hi Rick, Of course, there is. You can use exp://weblog:categories tag or exp://weblog:category_archive tag.
I guess I am being dense on how to use those when what I want is the CHILD category structure ONLY, based on the current category. Am I using one of these in conjunction with your plugin? If so, a tip where to plug it in would help.
Thanks! Rick
Hi Rick,
I’m not sure that I have understood you correctly.
Correct me if I a wrong.
1) You have three levels of categories. 2) Current category is the category of level 1 (that is, of highest level). 3) You need to display current category’s child categories (belonging to level 2) and their child categories (belonging to level 3).
1) You have three levels of categories. – Right now, yes, but I would like to go to 4 in some cases.
2) Current category is the category of level 1 (that is, of highest level). – Not necessarily. The template doesn’t know for sure that it is at the highest level. In the example I gave, EFT Resource & More is a top level category. Same code needs to work, though, if I am showing a level 2 category index.
3) You need to display current category’s child categories (belonging to level 2) and their child categories (belonging to level 3). – Yes, if I am at level 1. If at level 2, I’d like to show current category’s children and their child categories as well.
Current Category Name - Index
Clearer? And thanks so much for staying with me on this. I’d really like to get my site structure working smoothly, and your plugin has already helped considerably. I used to have the whole hierarchy displayed in the sidebar of every page!
Rick
Hi Rick,
There are no ExpressionEngine tags using which it is possible to display child categories of certain category.
There are two plugins which are able to do this : Child Categories and Subcategories.
Combining exp:weblog:categories tag together with Subcategories and Child categories plugins you can display up to four levels of categories. The code would be approximately as follows:
{exp:weblog:categories show="current_category_id"}
<!-- First level category -->
<a href="http://{path=template_group/template}">{category_name}</a>
{/exp:weblog:categories}
{exp:subcategories root_node="current_category_id" sort_by="category_name" parse="inward"}
<!-- Second level category -->
<a href="http://{path=template_group/template}">{category_name}</a>
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" entries_limit="5"}
{parent_category_start}
<!-- Third level category -->
<a href="http://{homepage}/{thisblog}/category/{parent_category_url_title}/">{parent_category_name} - Index</a>
{parent_category_end}
{child_category_start}
<!-- Fourth level category -->
- <b><a href="http://{homepage}/{thisblog}/category/{child_category_url_title}/">{child_category_name}</a></b> ({entries_total})
{child_category_end}
{/exp:child_categories}
{/exp:subcategories}
Hi - not sure why I’m not getting any data…all I need is a simple listing of my category names where the parent name equals segment_5 of the url. I’ve even tried hardcoding parent category ids, and it doesn’t work. This is the second plugin I’ve tried (the first, subcategories, worked great but did not allow for the “parent_node” parameter to pull in a segment variable. Here’s the code.
{exp:weblog:categories weblog="program_areas"}
{exp:child_categories parent="{segment_5}"}
{child_category_start}
{child_category_name}
{child_category_end}
{/exp:child_categories}
{/exp:weblog:categories}
<!--segment 5 would be a number, for example 12. Ideally, since I'm displaying the "category_name" in my URL, ex: index.php/site/program_detail/category/introduction/12, the best would be some way to pull in segment 4 ("introduction") and equate it as the parent_id somehow. But right now, even if I specify the parent as a hardcoded value, 12, it doesn't work. -->
What am I doing wrong. Is there a better way to do this? Thanks in advance!
Hi heaversm,
Doublecheck what characters you use for quoting parameters’ values.
Example of code in your post works when characters ” ” are changed into
""
Also consider if you really need to wrap exp:child_categories tag with exp:weblog:categories tag.
In order to convert category short name into category id you can use Category Id plugin.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.