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.

How do I include corresponding category names along with a list of weblog entries?

January 16, 2009 4:35pm

Subscribe [2]
  • #1 / Jan 16, 2009 4:35pm

    los1sol

    41 posts

    I’m sorry if this has been posted before. I searched the forum but did not find anyone who had this exact problem. I’m trying to create a list of entries using the exp:weblog:entries tag to generate a list of items corresponding to 1 particular weblog.

    However, I’m also trying to display the category under which each of these weblog entries falls. I have 4 different categories and my weblog entries all fall into one of them.

    Here is my problem, I can’t figure out how to pass the correct category value corresponding to each entry. Instead all 4 categories are showing up.  Can somebody please look at my code and tell me what I’m doing wrong?

    {exp:weblog:entries weblog="{test_project}" limit="20" status="Open|Closed"}
    {if count == "1"}
    <table>
    <tr>
    <th>ID</th>
    <th>Status</th>
    <th>Category</th>
    <th>Title</th>
    </tr>
    {/if}
    <tr>
    <td><a href="http://{permalink=test_project/detail}?id={entry_id}">{entry_id}</a></td>
    <td>{status}</td>
    <td>{exp:weblog:categories weblog="{test_project}"}{category_name}{/exp:weblog:categories}</td>
    <td>{title}</td>
    </tr>
    {if count == total_results}
    </table>
    {/if}
    {/exp:weblog:entries}

    It looks to me like the categories tag doesn’t know how to recognize which entry_id is being parsed so it’s just spitting out all the categories available (which is, in fact, what is happening). Am I missing an if statement or something?

  • #2 / Jan 17, 2009 8:25am

    liquilife

    147 posts

    The code below should work.

    {exp:weblog:entries weblog="{test_project}" limit="20" status="Open|Closed"}
    {if count == "1"}
    <table>
    <tr>
    <th>ID</th>
    <th>Status</th>
    <th>Category</th>
    <th>Title</th>
    </tr>
    {/if}
    <tr>
    <td><a href="http://{permalink=test_project/detail}?id={entry_id}">{entry_id}</a></td>
    <td>{status}</td>
    <td>{categories}{category_name}{/categories}</td>
    <td>{title}</td>
    </tr>
    {if count == total_results}
    </table>
    {/if}
    {/exp:weblog:entries}
  • #3 / Jan 20, 2009 4:02pm

    los1sol

    41 posts

    Thank you!

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

ExpressionEngine News!

#eecms, #events, #releases