We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Child Categories

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi Omma,

can you post your EE code in which exp:child_categories tag is being used?

       
Omma Creative's avatar
Omma Creative
26 posts
16 years ago
Omma Creative's avatar Omma Creative

Thanks for looking at this, and I can’t say thanks enough for your work on the plug in, even if it doesn’t work in this scenario, it really does help in other ones.

The a href isn’t right yet, I haven’t been fooling with that because I didn’t want to have segment variables be another confusing factor while debugging.

This does what it’s supposed to, produces each of the parent categories and their subcategories below them. The problem is I have no idea how to tie the UL to the parent and then make the child a li.ul .

<div id="leftcolumn">
<div id="leftdropdown">
      {exp:weblog:categories show="4|5|6|7|8|9" weblog="products"}
                <h3>{category_name}</h3>
      {exp:child_categories parent="{category_id}" child_categories_sort_by="custom"}
          {child_category_start}

<li><a href="http://{homepage}/{site_group}/{child_category_url_title}/">{child_category_name}</a></li>

          {child_category_end}
      {/exp:child_categories}

    {/exp:weblog:categories}
    
  </div>
</div>
       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi Luc,

Try to add double quotes around both {child_category_url_title} and {segment_4} and avoid white space after {segment_4}:

{exp:child_categories category_group="3"}

    {parent_category_start}
    <h2>{parent_category_name}</h2>
    <ul class="filter">
    {parent_category_end}
            

    {parent_wrapper_bottom_start}</ul>{parent_wrapper_bottom_end}

    {child_category_start}
    <li {if "{child_category_url_title}"=="{segment_4}"}class="selected"{/if}><a href="http://{homepage}gallery/view/category/{child_category_url_title}/">{child_category_name}</a></li>
    {child_category_end}

{/exp:child_categories}
       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi Omma,

Read my post here - there you will find example code showing how to tie parents and children to UL and LI elements.

       
vnystad's avatar
vnystad
3 posts
16 years ago
vnystad's avatar vnystad

Hi Laisvunas, and thanks for sharing this plug-in with the community - much appriciated 😊 Short question: Since it allows showing entries from multiple weblogs that share the same category group (great feature!), would it be possible to also sort children by weblog?

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi vnystad,

Currently it is not possibble to order child categories at first by weblog the by some other criterion.

If you needed to order entries posted into child categories at first by weblog then by some other criterion (date or title) by using together Child Categories plugin and Entries List plugin.

       
jason-cpt's avatar
jason-cpt
8 posts
16 years ago
jason-cpt's avatar jason-cpt

Hi,

Great plugin, thank you.

I’m just having trouble dynamically assigning the parent ID.

I’m using the {exp:weblog:entries} and {categories} tags as well as PHP to get the last category ID of the entry, however when I try assign this to the {exp:child_categories} tag, it returns all the parent categories (and not the sub-categories of the parent). When I use an actual value (and not a variable) it works well.

Please find below the code:

{exp:weblog:entries weblog=landing_page}
{categories}
<?php 
      $category_id = "{category_id}";
?>
{/categories}
{/exp:weblog:entries} 

<ul>
{exp:child_categories parent="<?= $category_id ?>" show_empty="yes"}
             {child_category_start}                
                    <li><a href="http://{parent_category_url_title}/{child_category_url_title}">{child_category_name}</a></li> 
             {child_category_end}
{/exp:child_categories}
</ul>

Any advice would be helpful.

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi Jason,

Try this code:

<ul>
{exp:weblog:entries weblog="landing_page" parse="inward"}
{categories}
{exp:child_categories parent="{category_id}" show_empty="yes"}
             {child_category_start}                
                    <li><a href="http://{parent_category_url_title}/{child_category_url_title}">{child_category_name}</a></li>
             {child_category_end}
{/exp:child_categories}
{/categories}
{/exp:weblog:entries}
</ul>
       
jason-cpt's avatar
jason-cpt
8 posts
16 years ago
jason-cpt's avatar jason-cpt

Thanks,

I’ve opted for a more manual solution, but will give this a try.

Many thanks for the quick response.

Jason

       
vnystad's avatar
vnystad
3 posts
16 years ago
vnystad's avatar vnystad
Currently it is not possibble to order child categories at first by weblog the by some other criterion.

OK, thanks anyway, I found a solution that seems to work - although I had to use a few extra lines of code. I’m building a project now that relies heavily on your plug-ins by now, Child Categories has certainly opened a few doors - I’ve never been happy with the way categories works out of the box with Expressionengine. I’m using Child Categories together with Find and Replace Plus to output JSON formatted data, and need to remove a comma after the last entry - but there is no backspace parameter. Is this something you plan to include in a future release?

       
LucPestille's avatar
LucPestille
146 posts
16 years ago
LucPestille's avatar LucPestille
Hi Luc, Try to add double quotes around both {child_category_url_title} and {segment_4} and avoid white space after {segment_4}:

That did the job, thanks!

       
james Brown's avatar
james Brown
492 posts
16 years ago
james Brown's avatar james Brown

Sorry if this has already been asked (the thread is pretty long now!), but how would I set the tag so that it gets any child category off the main category list. I see that it is easy to get it for specific parent categories. But what if I want it to be ANY child categories off of any of the main categories.

So for the example below it would automatically pull the child categories for the parent categories Pets, Furniture, and Plants. Then, if I added child categories for Artwork, it would add those as well. Does the plugin even allow for this?

Pets –dogs –cats –fish Furniture –couch –table –chair Artwork Plants –ferns –trees

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi James,

If Pets, Furniture, Artwork and Plants are parent categories from the same category group, then you can display all their children using parameter “category_group”, e.g.:

{exp:child_categories category_group="6"}
       
james Brown's avatar
james Brown
492 posts
16 years ago
james Brown's avatar james Brown

Ah ok. I knew it would be something simple!

Thanks

       
Jim Pannell's avatar
Jim Pannell
187 posts
16 years ago
Jim Pannell's avatar Jim Pannell

Hi Laisvunas

I’m trying to get the imgsizer plugin to resize my child_category_image photo but it doesn’t seem to be working (page loads fine but nothing is output where the image should be).

My code is as follows:

{exp:child_categories parent="5" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" entries_sort_by="date" entries_sort_direction="asc" site="2"}
{child_category_start}
    <h2><a href="/{my_template_group}/c/{child_category_url_title}/">{child_category_name}</a></h2>
    {exp:imgsizer:size src="{child_category_image}" width="100" alt="{child_category_name}"}
    {child_category_description}
{child_category_end}
{/exp:child_categories}

I’ve done a search of the forums but can’t see anything related to this - do you know if it’s possible for the imgsizer plugin to be parsed within the exp:child_categories tag or will I simply have to resize my images manually?

Cheers and thanks for a fab plugin - I’m loving it.

Jim

       
First 13 14 15 16 17 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.