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
15 years ago
Laisvunas's avatar Laisvunas

Hi Luc,

If you need to output one child category the entry was posted into, then it seems that you can achieve this using Entry Categories plugin.

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

Quick question here: I really appreciate this plugin and just have one question. I am using the children categories to generate a series of dynamic pages and it works great. On those pages I need to be able call the category id of that page to pull in the entries for that category.

I need something like this:

{exp:weblog:entries weblog="news" category_id={child_category}...}

How do I do this?

Thanks.

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

Hi,

Just add

parse="inward"

parameter to exp:child_categories tag and don’t forget quotes around “category” parameter:

{exp:weblog:entries weblog="news" category="{child_category_id}" ...}
       
fanderson's avatar
fanderson
883 posts
15 years ago
fanderson's avatar fanderson

Thank you for the prompt reply.

This is what I have done:

{exp:child_categories parse="inward" }
{exp:weblog:entries weblog="event" category="{child_category}" disable="trackbacks|pagination|member_data" }
<h3><a href="#">{title}</a></h3>
<div>
    <strong>Name of Organization</strong>: {organization}
    <strong>Location and Time</strong>:  {location_time} 
    <strong>Activity/responsibility</strong>: {event_description}
    <strong>Tools or skills required</strong>: {tools}
    <strong>Ages</strong>: {age_limit}
    <strong>Family Friendly</strong>: {family_friendly}
    <strong>Additional Notes</strong>: {additional_info}
    <strong>Download flyer</strong>: {flyer}
    <strong>Links</strong>: {link-1}

                               {link-2}
    {event_photo}
    <strong>Contact Person</strong>: {contact_person}

{/exp:weblog:entries}
{/exp:child_categories}

Is this correct - as it doesn’t appear to work.

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

Hi,

You should use not

{child_category}

but

{child_category_id}
       
fanderson's avatar
fanderson
883 posts
15 years ago
fanderson's avatar fanderson

Hi, unfortunately it is still not showing up properly. If I use category_id=”6” it works but with

{child_category_id}

That section of the page does not show up. Is there something else I could do to assist in resolving this? Thanks.

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

Hi,

If exp:child_categories tag does not work as expected with exp:weblog:entries tag, then check if these tags work correctly when used separately.

Also check this: exp:weblog:entries tag does not have parameter “category_id”; it has parameter “category”.

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

Hi,

I will try the first option to see what it brings back, but on the second point, I am using category not category_id with within the exp:weblog:entries tag. However, what needs to be brought in the the number, not the name - category=”60”.

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

Laisvunas,

I want to thank you for your excellent help. This plugin and the category id plugin have saved me countless hours of work. Sharing your expertise is true service. Thank you very much.

Forrest

       
ee_sa's avatar
ee_sa
56 posts
15 years ago
ee_sa's avatar ee_sa

Edit: Solved, look at the bottom!

Hi… great plugin 😊

I need some help

I want to display Parent as h1, and bellow to display all child’s. Problem is that I want always to show parent in H1, and bellow child’s on the same page.

For example:

Parent preview: www.domain.com/categories/list/computers

<h1>Computers</h1> – Hardware – Software

Child preview: www.domain.com/categories/list/hardware

<h1>Computers</h1> – Hardware – Software

Looks simple but I’m confused Thanks in advance

******** SOLUTION Maybe someone will need it sometime 😊

Template with include:

{exp:weblog:category_heading weblog="question" disable="pagination|trackbacks"}
  {if {parent_id} > 0}
    {embed="inc/.cat_heading" my_parent="{parent_id}"}
  {if:else}
    {embed="inc/.cat_heading" my_parent="{category_id}"}
  {/if}
{/exp:weblog:category_heading}

Include file:

{exp:child_categories parent="{embed:my_parent}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="yes" category_group="2"}

  {parent_category_start}
  <h1>{parent_category_name}</h1>
  {parent_category_end}
  <hr >
                 
  {child_category_start}
    <a href="http://{homepage}category/list/{child_category_url_title}" class="active">{child_category_name} ({entries_total})</a> 
  {child_category_end}
 
{/exp:child_categories}
       
Matthew Pennell's avatar
Matthew Pennell
221 posts
15 years ago
Matthew Pennell's avatar Matthew Pennell

Not sure if this is the “official” thread for this plugin, but here goes:

There’s a bug (as far as I can tell) with the {entries_total} tag - it doesn’t take the dates of an entry into account when calculating the count, so I have categories being listed with articles despite their publication date being in the future.

I’m about to dive into the plugin to see if I can figure out how to fix it - I’ll post here if I figure out a patch.

       
Matthew Pennell's avatar
Matthew Pennell
221 posts
15 years ago
Matthew Pennell's avatar Matthew Pennell

Here we go:

Around line 616 or so, replace this code:

// the case "show_expired" parameter is not set to "no"
            if ($show_expired !== 'no')
            {
              $entries_total = $querynext->num_rows;
            }
            // the case "show_expired" parameter is set to "no"
            else
            {
              $entries_total = 0;
              foreach($querynext->result as $rownext2)
              {
                //echo 'current_time: '.$current_time.' expiration_date: '.$rownext2['expiration_date'].'

';
                if ($current_time < $rownext2['expiration_date'] OR $rownext2['expiration_date'] == 0)
                {
                  $entries_total++;
                }
              }
            }

with this code, which compares the current time against the entry_date of the weblog entry before adding it to the count:

// the case "show_expired" parameter is not set to "no"
            if ($show_expired !== 'no')
            {
              $entries_total = 0;
              foreach($querynext->result as $rownext2)
              {
                if ($current_time >= $rownext2['entry_date'] OR $rownext2['entry_date'] == 0)
                {
                  $entries_total++;
                }
              }
            }
            // the case "show_expired" parameter is set to "no"
            else
            {
              $entries_total = 0;
              foreach($querynext->result as $rownext2)
              {
                if (($current_time >= $rownext2['entry_date'] OR $rownext2['entry_date'] == 0) && ($current_time < $rownext2['expiration_date'] OR $rownext2['expiration_date'] == 0))
                {
                  $entries_total++;
                }
              }
            }
       
Eastwood Design's avatar
Eastwood Design
605 posts
15 years ago
Eastwood Design's avatar Eastwood Design

I have a template that display all my parent categories like so:

{exp:weblog:categories weblog="links" cache="yes" refresh="100" style="linear" show_empty="no"}

                                   
<h2><a href="http://{path=site/links_sub}">{category_name}</a></h2>
                                       {if category_description}
                                         {category_description}
                                       {/if}

  {/exp:weblog:categories}

When you click the link (category_name), I want to go to a new template (links_sub) display the Parent Category name as a heading, then a sub heading of the 1st sub category then all the weblog entries in that sub category,

then the second sub category and all the weblog entries for the 2nd sub category, then the 3rd sub category etc.

The following code is not working of me.

{exp:weblog:categories category_group="3"  weblog="links" limit="1"}
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="99"}

{parent_category_start}
<h1>{parent_category_name}</h1>
{parent_category_end}

{child_category_start}
<h3>{child_category_name}</h3>
{child_category_end}

{entries_start}
<h2>{title}</h2>
{link_url}
{link_desc}
{entries_end}


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

it seems to display everything in the links weblog and the custom fields in the entries are not working as well. How do I limit it to just the parent and children categories based on the link segment. ie: http://site.com/index.php/site/links_sub/C47/

Where C47 is the ID of the parent category

any help is appreciated.

(EDIT: Solved the custom fields using the sing;le fields plugin and parse inward variable, but still having trouble limiting the category to just the one in the url C47, still displaying everything in the links weblog)

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

Hi,

Use in addition Find and Replace Plus plugin:

{exp:replace_plus find="C" parse="inward"}
{exp:weblog:categories category_group="3"  weblog="links" limit="1"}
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="99"}

{parent_category_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h1>{parent_category_name}</h1>
{/if}
{parent_category_end}

{child_category_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h3>{child_category_name}</h3>
{/if}
{child_category_end}

{entries_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h2>{title}</h2>
{link_url}
{link_desc}
{/if}
{entries_end}


{/exp:child_categories}
{/exp:weblog:categories} 
{/exp:replace_plus}
       
Eastwood Design's avatar
Eastwood Design
605 posts
15 years ago
Eastwood Design's avatar Eastwood Design

EDIT: SOLVED: forgot an additional parse inward tag. Working code below:

almost there, thanks for your tips on the find replace plus.

I now have the parent, chid, and entries displaying correctly.

but the custom fields in the entries are not displaying using the single field tag:

{exp:replace_plus find="C" parse="inward"}
{exp:weblog:categories category_group="3"  weblog="links" limit="1" style="linear"}
{exp:child_categories parent="{category_id}" child_categories_sort_by="custom" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="99" parse="inward"}

{parent_category_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h1>{parent_category_name}</h1>
{/if}
{parent_category_end}

{child_category_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h3>{child_category_name}</h3>
{/if}
{child_category_end}

{entries_start}
{if "{parent_category_id}" == "{replace_area}{segment_3}{/replace_area}"}
<h2>{title}</h2>
{exp:single_field field="link_url" entry_id="{entry_id}"}

{exp:single_field field="link_desc" entry_id="{entry_id}" field_format="raw"}
{/if}
{entries_end}


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

I am assuming this is something to do with the combination of the 2 plugins? single field and find replace plus?

TIA

       
First 19 20 21 22 23 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.