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.

Category entry count including empty categories

December 08, 2008 4:36pm

Subscribe [1]
  • #1 / Dec 08, 2008 4:36pm

    swillia1

    11 posts

    Hi All-
    I have searched for an answer to this, but haven’t found any previous questions that were answered.

    I am running a list of categories in a parent category with the number of entries posted beside them with this code:

    <ul class="four_column">
    {exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count, 
    exp_category_posts.cat_id, exp_categories.cat_name 
    FROM exp_categories, exp_category_posts, exp_weblog_titles 
    WHERE exp_category_posts.cat_id = exp_categories.cat_id 
    AND parent_id='318' 
    AND exp_weblog_titles.weblog_id = '9' 
    AND exp_weblog_titles.entry_id = exp_category_posts.entry_id 
    GROUP BY exp_categories.cat_name"}
    <li><a href="http://{path=site/fw_index4_listings}C{cat_id}/">{cat_name}</a> ({post_count})</li> 
    {/exp:query} 
    </ul>

    It works beautifully on returning categories that have entries, but I want it to also return categories that have no entries with a zero. Can anyone point me in the right direction here?

    Thanks a million!

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

ExpressionEngine News!

#eecms, #events, #releases