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.

issue displaying entries from specified category

March 16, 2011 5:08am

Subscribe [2]
  • #1 / Mar 16, 2011 5:08am

    ggoforth

    119 posts

    Hello, I’m creating a blog using EE and have a sidebar that lists all the categories for a specified channel (in this case, channel=‘blog’).  The link I’m creating for each category has an href like this:

    http://mydomain.com/blog/category/2

    So template group blog, category is the template, and 2 is the category id.  In the category template I have the exp tag:

    {exp:channel:entries channel='blog' category='{segment_3}' orderby='date' sort='desc' limit='5' paginate='bottom'}
    ...
    {/exp:channel:entries}

    The issue I’m having is that nothing inside the exp block is being parsed, and no entries are showing up.  Anything obvious stick out that I might be doing wrong?  Also, the exact same exp tag is being used on my blog index template (sans the category attribute) and it’s working perfectly.  So, I’m kind of at a loss as to what is going on here.  Thanks for any help!

    Greg

  • #2 / Mar 16, 2011 7:33am

    Cheif

    626 posts

  • #3 / Mar 16, 2011 1:57pm

    Lisa Wess

    20502 posts

    Hi, Greg -

    It looks like you’re reinventing the wheel here.  Right now, EE thinks your segment_3 is an entry ID, which is why it’s not working.  Why not use EE’s built-in dynamic abilities to achieve this? 

    Have a look at The Importance of Semantics: Displaying Categories for a quick run-down.

    Does that help?

  • #4 / Mar 16, 2011 5:50pm

    ggoforth

    119 posts

    I will give that link a read Lisa.  Cheif’s suggestion did fix my problem, but if I’m doing it in an strange way then maybe I should change it.  Thanks!

  • #5 / Mar 16, 2011 6:11pm

    ggoforth

    119 posts

    Thanks for the info Lisa, I gave your article a read, but it’s still not working as expected (but I think I’m close).  For what it’s worth, Cheif’s suggestion did fix the problem, but I had to have a seperate template for categories when really I just want my blog/index template.  So, that said, here is my code for the blog/index template.  This works perfectly when I first visit the blog.

    {exp:channel:entries channel='blog' orderby='date' sort='desc' limit='5' paginate='bottom'}
        <div class='entry'>
            <h2 class='blog_title'>{title}</h2>
            <div class='blog_date'>Posted on: {entry_date format="%F %d %Y"} by {username}</div>
             {if blog_summary}
                 {blog_summary}
                 <div class='comments'>
                     Comments: {total_comments}
                 </div>
                 <a href="http://{title_permalink=%22blog/article%22}" class='read_more'>Read More →</a>
             {if:else}
                 {content}
                 <div class='comments'>
                    Comments: {total_comments}
                 </div>
             {/if}
             <div class='tags'>
                 Tags: {embed='_site/tags' entry_id='{entry_id}'}
             </div>
             <div class='clear'></div>
        </div>
        {paginate}
           <div id='pagination'>{pagination_links}</div>
        {/paginate}
    {/exp:channel:entries}

    Now, my categories are output with the following code (updated to reflect reusing the blog/index template instead of a separate blog/category template).

    {exp:channel:categories channel='blog'}
        <a href="http://{path=blog/index}">{category_name}</a>
    {/exp:channel:categories}

    Which create links to “http://mydomain.com/blog/category/features” (features being the name of the category, and I do have the preference enabled to use category names)

    When I click one of those links I get nothing out put for the entries. I feel like I’m missing something small, but hopefully you might see something I’m missing.

    Thanks again for your help!

  • #6 / Mar 16, 2011 6:16pm

    ggoforth

    119 posts

    Just discovered something interesting.  For outputting my category links I’m using “{path='blog/index'}” which creates a link like “http://mydomain.com/blog/category/features”.  This link fails to load anything.  If I manually add the index after blog, it loads the categories just fine.  So this link works “http://mydomain.com/blog/index/category/features”

    Any idea why the {path='blog/index'} is removing the index portion of the url?

  • #7 / Mar 16, 2011 6:32pm

    ggoforth

    119 posts

    Ah, so I’m an idiot 😊  I still had a category template in my blog group that was all foobared.  Deleting that template and just using my multi entry blog/index template and it’s working like a charm!  Thanks for the help!

  • #8 / Mar 17, 2011 11:37am

    Brandon Jones

    5500 posts

    Awesome! Glad Lisa helped, and feel free to post again with other questions.

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

ExpressionEngine News!

#eecms, #events, #releases