Displaying entries for each category in ExpressionEngine

So, I searched and found some messages that bother me that I want, but it still does not work. This post especially seemed the closest to what I was trying to achieve, and I built my code: http://expressionengine.com/forums/viewthread/168142/

Explain I have a series of entries, each entry is assigned to only one category. I would like to list these categories and under each category list entries with one of my custom fields. For instance:

  • Category 1

    • Paragraph 1
    • Point 2
  • Category 2

    • Paragraph 1
    • Point 2

So, here is my code in its current form, which lists the categories, but none of the entries spit out:

{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 inline template that it refers to:

 {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 appreciated!

+4
source share
3 answers

So here is what I ended up at the end (kindly helped on EE boards):

 {exp:channel:categories channel="faq-camp" style="linear" show_empty="no"} <section class="faq-category-container closed"> <h1 class="faq-category-header"><a href="#">{category_name}</a></h1> <div class="faq-questions-container"> <dl> {embed="jazz-camp/faq-cat-list" faqlink="{category_id}" faqparent="faq-camp"} </dl> </div><!-- end .faq-questions-container --> </section><!-- end .faq-category --> {/exp:channel:categories} 

As for embedding, it looks like this:

 {exp:channel:entries channel="{embed:faqparent}" category="{embed:faqlink}" dynamic="no"}<!-- entries --> <dt>{title}</dt> <dd> {faq_answer} </dd> {/exp:channel:entries} 

The reason for embedding is related to how things are pulled in relation to getting the right channel entries; just the presence of {exp:channel:entries} inline on the page did not work.

+4
source

This can be a very simple example of what you need:

 {exp:channel:categories style="linear"} <h1>{category_name}:</h1> {exp:channel:entries category="{category_id}"} <p>{my_custom_field}</p> {/exp:channel:entries} {/exp:channel:categories} 
+13
source
+1
source

Source: https://habr.com/ru/post/1334871/


All Articles