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.

categories trouble

April 07, 2010 6:57am

Subscribe [2]
  • #1 / Apr 07, 2010 6:57am

    shellfish

    48 posts

    Hey,

    I’m trying to build a blog in EE and am having some trouble displaying categories that a weblog entry is posted into alongside the number of comments. 

    The comments portion is working fine, but it is currently displaying all categories rather than just the one/s the entry is posted into.  Here’s my code:

    {exp:weblog:entries weblog="books"}
    <div class="books">
    <h3><a href="http://{title_permalink=">{title}</a></h3>
    <h4>{authors}</h4>
    <p>{short_info}<br />
    {thumb_img}</p><h5>{price}</h5>
    
    <p>Posted in: </p>
    
    <p>{exp:weblog:categories weblog="books" style="nested" id="category_nav" show_empty="no" }<br />
             <a href="http://{path=books/list}">{category_name} </a>| </p>
    
    <p>{/exp:weblog:categories} | comments {comment_total}</p>
    
    <p></div><br />
    {/exp:weblog:entries}

    Any tips on what I’ve done wrong?

    I’m trying to achieve the ‘posted in’ and ‘comments’ as seen here:  http://tiny.cc/g0f2w

    Thanks.

    Shell

  • #2 / Apr 07, 2010 1:47pm

    Gareth Davies

    491 posts

    Hi Shell,

    You are using the wrong tag to pull your category data - that tag is supposed to pull all the categories hence it is.

    You need the {categories} variable pair as seen here:

    http://expressionengine.com/docs/modules/weblog/variable_pairs.html#var_categories

    So should be:

    Posted in:
    
    {categories}<a href="http://{path=books/list}">{category_name} </a>{/categories}  | comments {comment_total}
  • #3 / Apr 07, 2010 2:39pm

    shellfish

    48 posts

    Thanks Gareth….all makes sense now!

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

ExpressionEngine News!

#eecms, #events, #releases