We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Show entry listings organized by category

Development and Programming

elative's avatar
elative
8 posts
15 years ago
elative's avatar elative

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://ellislab.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!

       
Rob Sanchez's avatar
Rob Sanchez
335 posts
15 years ago
Rob Sanchez's avatar Rob Sanchez

Why not use the category parameter? http://ellislab.com/expressionengine/user-guide/modules/channel/parameters.html#par_category

{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>
        {embed="jazz-camp/faq-cat-list" faqlink="{category_id}"}
        </dl>
    </section><!-- end .faq-category -->
{/exp:channel:categories}
{exp:channel:entries channel="faq-question" category="{embed:faqlink}" dynamic="no"}<!-- entries -->
    <dt>{title}</dt>
    <dd>
        {faq_content}
    </dd>
{/exp:channel:entries}
       
elative's avatar
elative
8 posts
15 years ago
elative's avatar elative

I’d almost gotten there; I had started using the category parameter, but had the channel entries bit in the same file & it wasn’t quite working, but your code works precisely how I need it to!

Thanks very much for getting me over the hump, cheers!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.