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

NNWebmaster's avatar
NNWebmaster
43 posts
15 years ago
NNWebmaster's avatar NNWebmaster

I’m not sure if this has anything to do with the future entries bug but my code is acting strangely. It doesn’t seem to be showing the entries consistently on the page. In some child categories I’m only getting one entry displayed and in others I’m seeing three. Some have none at all. Here’s my code:

{exp:child_categories parent="{embed:parent_id}" child_categories_sort_by="name" child_categories_sort_direction="asc" show_empty="no" entries_sort_direction="desc" entries_limit="3" entries_sort_by="date" parse="inward"}
{child_category_start}
<h3><a href="http://{homepage}articles/category/{parent_category_url_title}/{child_category_url_title}/">{child_category_name}</a></h3>
{child_category_end}
{entries_wrapper_top_start}<ul class="cat-news">{entries_wrapper_top_end}
{entries_start}
 {exp:weblog:entries weblog="news_articles" status="not closed|pending" entry_id="{entry_id}" show_future_entries="no" show dynamic="off" disable="member_data|pagination|trackbacks|categories"}
<li> 
   <a href="http://{path=articles/view}{url_title}" title="{title}">{exp:imgsizer:size src="{article_photo}" width="200" height="200" alt="{title}" class="sImage" base_path="****" base_cache="****"}{/exp:imgsizer:size}</a>
   <a href="http://{path=articles/view}{url_title}">{title}</a>
     {exp:md_eexcerpt if_exceeds="20" stop_after="15"}
   {exp:single_field field="article_excerpt" entry_id="{entry_id}"}
 {/exp:md_eexcerpt}
 </li>
{/exp:weblog:entries} 
{entries_end}
{entries_wrapper_bottom_start}</ul><div class="clearfix"></div>{entries_wrapper_bottom_end}
{/exp:child_categories}

UPDATE: Never mind. I just updated the plugin. Seems to have done the trick.

       
Dennis Frank's avatar
Dennis Frank
12 posts
15 years ago
Dennis Frank's avatar Dennis Frank

Hi,

is it possible to output a custom category fields?

I tried to use {exp:weblog:categories show="{child_category_id}"} but it does not work for me:

{exp:child_categories category_group="4" weblog="{segment_1}" show_empty="no"}
    {parent_category_start}
        <optgroup label="{parent_category_name}">
    {parent_category_end}
        {child_category_start}
            <option value="{child_category_url_title}">
                {exp:weblog:categories category_group="4" show="{child_category_id}" weblog="{segment_1}" style="linear"}
                    {custom_category_field}
                {/exp:weblog:categories}
            </option>
        {child_category_end}
    {parent_wrapper_bottom_start}
        </optgroup>
    {parent_wrapper_bottom_end}
{/exp:child_categories}

Any ideas?

       
Dennis Frank's avatar
Dennis Frank
12 posts
15 years ago
Dennis Frank's avatar Dennis Frank

So this seems to work:

{child_category_start}
    <option value="{child_category_url_title}">
        {exp:weblog:categories category_group="4" weblog="{segment_1}" show="{parent_category_id}|{child_category_id}" show_empty="yes" style="linear"}
            {if category_id != "{parent_category_id}"}
                {custom_category_field}
            {/if}
        {/exp:weblog:categories}
    </option>
{child_category_end}

I had to include the parent category id in the show attribute and then filter it out again:

{if category_id != "{parent_category_id}"}

.

Not very elegant but it works.

       
fanderson's avatar
fanderson
883 posts
15 years ago
fanderson's avatar fanderson

I have a section on a website that uses categories for organizing articles. I use the categories as navigation for this site and will be using this navigation to link to a page that displays that Parent Category Title and all associated entries as well as all child categories of that parent and their associated entries.

I would like the end result to look like this:

<h2>Category Title</h2>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>    

<h3>Sub-cateogry 1 Title</h3>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    
<h3>Sub-cateogry 2 Title</h3>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>    
    
<h3>Sub-cateogry 4 Title</h3>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>
    <a href="#">Entry Title</a>

I tried using this code, but it only displayed the category titles:

{exp:weblog:categories category_group="2"  weblog="articles"}
{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" site="1"}
        
{parent_category_start}
  <a href="http://{site_url}topic/{parent_category_id}">{parent_category_name}</a>

{parent_category_end}

{entries_start}
    <a href="http://{site_url}topic/{parent_category_id}/{url_title}/">{title}</a>

{entries_end}
        
{child_category_start}
  <a href="http://{site_url}topic/{child_category_id}">{child_category_name}</a>

{child_category_end}
        
{entries_start}
    <a href="http://{site_url}topic/{child_category_id}/{url_title}/">{title}</a>

{entries_end}

 {/exp:child_categories}
{/exp:weblog:categories}

I am obviously missing something here and would appreciate some help. Thanks.

       
justinviger's avatar
justinviger
36 posts
15 years ago
justinviger's avatar justinviger

Hello. I am having a problem that I think this plugin and the category_id plugin together should be able to fix, but I am not sure why it isn’t working. Here is the code:

{exp:weblog:entries weblog="sr_province" url_title="{segment_1}" dynamic="off"}
                    {sr_map}
                    <h1>Snowmobiling in {title}</h1>
                    {sr_intro}
                {/exp:weblog:entries}
                <ul id="articlelinks">
                    {exp:category_id category_group="14" category_url_title="{segment_1}" parse="inward"}
                        {exp:weblog:entries weblog="sr_region" category="{category_id}" orderby="sr_entry_order" sort="asc" dynamic="off"}
                            <li>
                                {sr_summary_map}
                                <h3><a href="/{segment_1}/{url_title}/">{title}</a></h3>
                                {sr_summary}
                                <h4>Snowmobile locations</h4>
                                <ul>
                                    {exp:category_id category_group="14" category_url_title="{url_title}" parse="inward"}
******                                 {exp:child_categories parent="{category_id}" parse="inward"}
                                            {child_category_start}
                                                <li>
                                                    <a href="/{segment_1}/{url_title}/{child_category_url_title}/">_                                                        {child_category_name}_                                                    </a>
                                                </li>
                                            {child_category_end}
                                        {/exp:child_categories}
                                    {/exp:category_id}
                                </ul>
                            </li>
                        {/exp:weblog:entries}
                    {/exp:category_id}

Basically I need show content based on three levels on categories. Since it is destinations I have categories for canada and usa and then within canada I have province and within that regions and then within that I have cities. So for British Columbia page I need to show entry content for an entry called British Columbia. Then I need to list all regions tagged with the category British Columbia. and with the list of regions I need to list all cities that have been tagged as children of the region category.

It’s pretty much all working except for the one category_id tag, on the line I added the ****** to, is not showing the category_id of the region. If I type in a specific category_id it works, so I am assuming it is not getting the category_id using the category_id plugin, but I am not sure why.

Can anyone tell me if some of my code is a bit wrong? Or maybe I am going about this way wrong.

       
Jonathan Schofield's avatar
Jonathan Schofield
175 posts
15 years ago
Jonathan Schofield's avatar Jonathan Schofield

Hi Laisvunas,

I love this plugin and, like one or two others who have asked, I wonder if you have any plans to make it EE2 compatible, especially now the end of beta is officially ‘near’?

I would pay to help its development. Any other takers?

       
fanderson's avatar
fanderson
883 posts
15 years ago
fanderson's avatar fanderson

Hi Laisvunas,

I figured it out. I was able to achieve my desired results as follows:

{exp:category_id category_group="2" category_url_title="{segment_2}" parse="inward"}    
            {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="3" site="1"}
                {parent_category_start}
                <h1><a href="http://{homepage}/category/{parent_category_url_title}/">{parent_category_name}</a></h1>
                {parent_category_end}
                {child_category_start}
                <h2><a href="http://{homepage}/category/{child_category_url_title}/">{child_category_name}</a></h2>
                Total entries: {entries_total}

                {child_category_end}
                {entries_wrapper_top_start}<ul>{entries_wrapper_top_end}
                {entries_start}
                <li><a href="http://{weblog_url}{url_title}/">{title}</a> Weblog: {weblog_name}, posted: {entry_date}</li>
                {entries_end}
                {entries_wrapper_bottom_start}</ul>{entries_wrapper_bottom_end}
            {/exp:child_categories} 
        {/exp:category_id}

Awesome plugins! Thank you.

       
awa's avatar
awa
77 posts
15 years ago
awa's avatar awa
Hi Laisvunas, I would pay to help its development. Any other takers?

I´d be interested too.

Cheers awa

       
awa's avatar
awa
77 posts
15 years ago
awa's avatar awa

Hi Laisvunas, have you ever thought of going commercial with your plugin? I be happy to pay 10€ - 15€ for THE category plugin, which I think “cild categories” can evolve into. Frankly, I think, that EEs native category management capabilitys have room for improvment.

I´s like to have a cat plugin, that could be used in a - single tag version - version with opening and closing tags

The single tag version would be used with “parse=inward” as Elis plugin VZ Subcategories. (see http://ellislab.com/forums/viewthread/129357/). It would be the input for the categories parameter of all those other tags.

The variant with opening and closing tags would display the categories as a list.

Both varants should be extremly configurable. Basically the plugin should take an category ID (wether static or dynamic) and then I would love to see

  • level parameters. Go x levels up or down in the hierarchy starting from where you are

  • offset parameters. Go x levels up or down, but DON´T display the next y levels. Example: you´ re on level 3 and want to go 2 levels up, means you end up on the top level. Offset set to 1 would only display the given category + the top level categories, leaving out all cats on level 2.

  • Display limitation (show only x cats)

  • plus all the stuff, that´s already in. And ported to EE2.

Basically it would be a plugin, that would be the swiss knife converning category manipulation.

What do you think?

Cheers awa

       
russlipton's avatar
russlipton
305 posts
15 years ago
russlipton's avatar russlipton

I would also pay for this for EE2. Come on, Laisvunas, please bequeath your addon lore to the new platform, despite your reservations 😉.

       
Mobster's avatar
Mobster
64 posts
8 years ago
Mobster's avatar Mobster

I’m using child categories to output json for a chained dropdown.

My question is, is it possible if the parent category doesn’t have a child to display the entries within the parent instead?

Like… Maybe?

{exp:http_header content_type="application/json"}
[
  [ "", "--" ],
{if "{exp:child_categories category_group="2" parent="{get:mark}" url_title="{get:mark}"  show_empty="no" parent_categories_sort_by="custom" child_categories_sort_by="custom"}" != ""}
     {child_category_start}
  [ "{child_category_name}", "{child_category_name} - {entries_total}" ],
     {child_category_end}
  {/exp:child_categories}
{if:else}

Regular Category tag pair.  

{/if}
  [ "selected", "Other" ]
]
       
First 23 24 25

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.