EllisLab text mark
Advanced Search
     
Need Category Archive to Display Parent Cat + Entries and Children Cats + Entries
Posted: 16 October 2011 01:18 PM   [ Ignore ]
Avatar
Joined: 2008-02-09
46 posts

I have a dynamic navigation of parent categories that utilize the category_url_title.  When I click the link, the subsequent template needs to list thusly:

Parent Category Title
- entry 1
- entry 2

Child Category
  - entry 3
  - entry 4

Right now, I can only get the Parent Category and its entries to display.  The code I’m using to do this is:

{exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_4}'"}
    {exp
:weblog:category_archive weblog="publications" show="{cat_id}" style="nested"}
        {categories} 
<a href="{path='weblog/template'}">{category_name}</a>{/categories}
        {entry_titles} 
<a href="{path='weblog/template'}">{title}</a>{/entry_titles}
    {
/exp:weblog:category_archive}
{
/exp:query} 

Thanks in advance for any advice you may have. (EE v 1.6.9)

[Mod Edit: Moved to the Community Help forum]

 Signature 

Wiley Koepp
@wileykoepp
@coyotemusic

 
Posted: 17 October 2011 08:31 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
981 posts

Hi,

You can achieve what you need by using Child Categories plugin.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 17 October 2011 08:48 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2002-04-29
26055 posts

Thanks for the assist, Laisvunas.

I also use something like this:

{exp:channel:category_archive channel="howto" show_empty="no"}


{categories}
<h3>{category_name}</h3>
<
p>Number of entries{exp:catcount cat_id="{category_id}" status="open|closed"}</p>
{/categories}

{entry_titles}
<a href="{path=howto/articles}">{title}</a>{/entry_titles}

{
/exp:channel:category_archive} 

(catcount is a third party plugin that does a count of the entries.)

That code will also show items that are child categories. See example linked below.

 
Posted: 17 October 2011 05:51 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2008-02-09
46 posts

Thanks, both of you. Sue, ideally I’d like to use code like you’ve written.  However, my page should only show a parent category (specified in the URL via category_url_title) and all of its entries, child-categories & their entries.

If I use the code you suggested, I get all Categories, their children, all child categories, and all their entries.

Can I dynamically limit to a single parent category?

Laisvunas, I’m looking into your suggested plugin now.  Thanks!

 Signature 

Wiley Koepp
@wileykoepp
@coyotemusic

 
Posted: 18 October 2011 06:30 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
981 posts

Hi Wiley,

You can dynamically limit parent categories to a single parent category by using together Category Id and Child Categories plugins:

{exp:category_id category_group="1" category_url_title="{segment_3}" parse="inward"
{exp
:child_categories parent="{category_id}" child_categories_sort_direction="asc" show_empty="no" entries_sort_by="date" entries_sort_direction="asc" entries_limit="5" site="1"}

Some code to display parent category
child categories and entries
 
{
/exp:child_categories}
{
/exp:category_id} 
 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 09 August 2012 11:25 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2008-02-09
46 posts

Thanks Laisvunas.  This deliverable took a backseat for a while.  I have Child Categories now, though, and may be implementing this in the near future.  I’ll reply back here if/when this task gets implemented.  Thanks for the advice!

 Signature 

Wiley Koepp
@wileykoepp
@coyotemusic