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.

Display all items in category

October 19, 2011 4:45pm

Subscribe [2]
  • #1 / Oct 19, 2011 4:45pm

    dodgson

    120 posts

    It seems that I need to re-learn this stuff every time I come back from taking a break. I have created a menu that lists all categories. I can’t seem to figure out how I make each category link go to a new page that shows all posts that are within that category. Any suggestions.

    Thanks in advance.
    Mark

  • #2 / Oct 19, 2011 4:57pm

    dodgson

    120 posts

    I found this and it is producing the column of categories with the number of posts in each category, however I’m not sure how to create the link to go to the view page that will display all posts within that category.

    {exp:query sql="SELECT 
                    count( exp_category_posts.entry_id ) AS count, 
                    exp_category_posts.cat_id, 
                    exp_categories.cat_name 
                FROM exp_categories LEFT OUTER JOIN exp_category_posts 
                ON exp_category_posts.cat_id = exp_categories.cat_id 
                GROUP BY exp_categories.cat_name
                "} 
                    <ul>
                     <li><a href="http://{path=blog/blogView/{category_url_title}}">{cat_name}</a> ({count})</li>
              </ul>
                {/exp:query}
  • #3 / Oct 25, 2011 9:51am

    Boyink!

    5011 posts

    You are trying too hard..😉

    Let EE’s dynamic nature do the work for you.

    First - create a template that lists alll entries in the channel.  Don’t force categories in anyway.  You want the full laundry list.

    Second - create category links that link to the template you just created.  You create category links by using tag pairs like {exp:channel:categories} using the {path} variable in the loop.  EE will create links that have either the category url title or category ID in the URL. 

    When the template you created is linked to with a category link, EE will automatically filter the results down to just entries assigned to that category.

  • #4 / Oct 25, 2011 9:53am

    dodgson

    120 posts

    Thanks Boyink. Very much appreciated.

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

ExpressionEngine News!

#eecms, #events, #releases