Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying entries per category in ExpressionEngine

So, I've searched, and found a few posts that kinda get me what I want, but it still doesn't quite work. This post especially seemed closest to what I was trying to achieve, and I built my code off of it: http://expressionengine.com/forums/viewthread/168142/

To explain; I have a series of entries, each entry is assigned to only one category. I'd like to list out these categories and, beneath each category, list out the entries with one of their custom fields. Like so:

  • Category 1

    • Item 1
    • Item 2
  • Category 2

    • Item 1
    • Item 2

So, here's my code as it stands now, which lists out the categories, but doesn't spit out any of the entries at all:

{exp:channel:categories channel="faq-question" style="linear"}
    <section class="faq-category-container closed">
        <h1 class="faq-category-header"><a href="#">{category_name}</a></h1>
        <dl>
    {exp:query sql="

        SELECT title, url_title AS urlt, cat_id

        FROM exp_channel_titles

        NATURAL JOIN exp_category_posts

        WHERE channel_id = '7' AND cat_id = '{category_id}'

        ORDER BY title ASC"
    }
        {embed="jazz-camp/faq-cat-list" faqlink="{urlt}"}
    {/exp:query}
        </dl>
    </section><!-- end .faq-category -->
{/exp:channel:categories}

And the embedded template it references:

{exp:channel:entries channel="faq-question" url_title="{embed:faqlink}"}<!-- entry -->
    <dt>{title}</dt>
    <dd>
        {faq_content}
    </dd>
{/exp:channel:entries}

Any help would be most appreciated!

like image 892
jeffbyrnes Avatar asked Jan 10 '11 01:01

jeffbyrnes


1 Answers

This may be a very basic example of what you're after:

{exp:channel:categories style="linear"}
  <h1>{category_name}:</h1> 
  {exp:channel:entries category="{category_id}" dynamic="no"}
    <p>{my_custom_field}</p>
  {/exp:channel:entries}
{/exp:channel:categories}
like image 194
hoosteeno Avatar answered Oct 02 '22 16:10

hoosteeno