ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Need Category Archive to Display Parent Cat + Entries and Children Cats + Entries

October 16, 2011 1:18pm

Subscribe [3]
  • #1 / Oct 16, 2011 1:18pm

    wiley

    37 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="http://{path=weblog/template}">{category_name}</a>{/categories}
            {entry_titles} <a href="http://{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]

  • #2 / Oct 17, 2011 8:31am

    Laisvunas

    879 posts

    Hi,

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

  • #3 / Oct 17, 2011 8:48am

    Sue Crocker

    26054 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"}<br />
    {/categories}</p>
    
    <p>{entry_titles}<a href="http://{path=howto/articles}">{title}</a>{/entry_titles}</p>
    
    <p>{/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.

  • #4 / Oct 17, 2011 5:51pm

    wiley

    37 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!

  • #5 / Oct 18, 2011 6:30am

    Laisvunas

    879 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}
  • #6 / Aug 09, 2012 11:25am

    wiley

    37 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!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases