2011-01-10 126 views
4

所以,我搜索了一下,发现有几篇文章让我得到我想要的东西,但它仍然不起作用。这篇文章似乎最接近我想要实现的目标,并且我建立了我的代码:http://expressionengine.com/forums/viewthread/168142/在ExpressionEngine中显示每个类别的条目

解释;我有一系列条目,每个条目只分配给一个类别。我想列出这些类别,并在每个类别下面,列出其中一个自定义字段的条目。像这样:

  • 1类

    • 项目1
    • 项目2
  • 类别2

    • 项目1
    • 项目2

所以,这里是我的代码,目前的情况是,其中列出了类别,但是并不在全吐了出来任何条目:

{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} 

和嵌入式它参考的模板:

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

任何帮助将不胜感激!

回答

4

所以,这里是我结束了在最后(有一定的帮助礼貌了在EE板):

{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} 

至于嵌入,它看起来像这样:

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

的原因嵌入有做事情如何被拉入关于获得正确的频道条目;简单地在网页中嵌入{exp:channel:entries}并不完美。

13

这可能是你以后一个非常简单的例子:

{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} 
+0

是啊,这是什么,我结束了与基本版。我创建了另一个答案来展示我最终使用的内容。 – jeffbyrnes 2011-01-28 15:50:32

相关问题