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.

Looping through categories

September 29, 2010 2:45am

Subscribe [1]
  • #1 / Sep 29, 2010 2:45am

    Greazer

    2 posts

    Hi everyone,
    Just wondering if someone might have a better way to go about what I wish to achieve.

    I plan to publish various documents to their specific category. I also want to make sure I can take advantage of the tags {category_name} and {category_description}

    like so :

    Category 1
    This is the description of category 1
    - file 1
    - file 2

    Category 2
    ]This is the description of category 2
    - file a
    - file b
    - file c

    Here is what I am using currently, but I will have to add this loop for every specific catagory i wish to display.

    This example will only list documents for ‘Category 1’

    {exp:channel:categories channel="document" show="1"}
    {category_name}
    {category_description}
                
    {exp:channel:entries category="1" channel="document"}
    {title}
    {document_description}
    {/exp:channel:entries}
    
    {/exp:channel:categories}

    Is there a better way to go about this, so i only have 1 loop that spits out the category name, its description, its related files, for each category , one after the other ?

    Thanks in advance.

  • #2 / Sep 29, 2010 3:15am

    Cheif

    626 posts

    This should do it… Full description here:

    {exp:channel:category_archive channel="default_site" style="linear"}
    
    {categories}
    <h3>{category_name}</h3>
    <p>{if category_description}{category_description}{/if}<br />
    {/categories}</p>
    
    <p>{entry_titles}<br />
    <a href="http://{path=SITE_INDEX}">{title}</a></p>
    
    <p>{/entry_titles}</p>
    
    <p>{/exp:channel:category_archive}

  • #3 / Sep 29, 2010 3:18am

    Greazer

    2 posts

    Thanks cheif, appreciated

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

ExpressionEngine News!

#eecms, #events, #releases