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.

Listing entries mixed with categories

July 20, 2007 2:15pm

Subscribe [0]
  • #1 / Jul 20, 2007 2:15pm

    I would like to create an alphabatized list of all the uncategorized entries and categories with their entries for one weblog.

    Entry A
    Entry B
    Entry C
    Category C
       Cat C Entry A
       Cat C Entry B
       Cat C Entry C
    Entry D
    Entry F
    Category F
       Cat F Entry A
    Entry G
  • #2 / Jul 20, 2007 5:00pm

    I think what I could do is categorize everything but treat how the listings are treated differently by counting the number of entries in each category somehow and using conditionals.

    Is there a variable that will give me a count of the number of entries in a category? How are the counts done in the EE Knowledge Base? (though at the moment the counts there all say “1”)

  • #3 / Jul 20, 2007 5:07pm

    Lisa Wess

    20502 posts

    Check out this wiki entry for the category count.  I’ve notified our web team about the KB entries counts, thank you!

  • #4 / Jul 20, 2007 5:45pm

    Thanks! I’ve tested the second method in the wiki entry but am not getting any data populating the counts.

    This is the code I used. What am I missing?

    {exp:weblog:categories weblog="policies_procedures"}
    <a href="http://{path=policies_procedures/details}">{category_name}</a>
    {exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count FROM exp_category_posts WHERE exp_category_posts.cat_id = {category_id}"}
    ({post_count} entries)
    {/exp:query}
    {/exp:weblog:categories}
  • #5 / Jul 22, 2007 6:25pm

    I have tried both methods from the wiki entry. I have very little experience with writing SQL queries so don’t know where to go from here.

    Test Page

    The first method does not populate the counts while the second method does.

    This is the template code:

    <h2>Method One</h2>
    <p>{exp:weblog:categories weblog="about_us"}<br />
    <a href="http://{path=about_us/details}">{category_name}</a> {exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count FROM exp_category_posts WHERE exp_category_posts.cat_id = {category_id}"}({post_count} entries){/exp:query}<br />
    {/exp:weblog:categories}</p><h2>Method Two</h2>
    <p><ul><br />
    {exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count, exp_category_posts.cat_id, exp_categories.cat_name<br />
    FROM exp_categories, exp_category_posts, exp_weblog_titles WHERE exp_category_posts.cat_id = exp_categories.cat_id AND parent_id='0'<br />
    AND exp_weblog_titles.weblog_id = '9'<br />
    AND exp_weblog_titles.entry_id = exp_category_posts.entry_id<br />
    GROUP BY exp_categories.cat_name"}<br />
    <li><a href="http://{path=about_us/details}C{cat_id}/">{cat_name}</a> ({post_count} {if post_count > 1}entries{if:else}entry{/if})</li><br />
    {/exp:query}

    Any help is greatly appreciated.

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

ExpressionEngine News!

#eecms, #events, #releases