在 ExpressionEngine 中显示每个类别的条目
因此,我进行了搜索,发现了一些帖子可以满足我的需求,但仍然不太有效。这篇文章似乎最接近我想要实现的目标,我根据它构建了我的代码: http: //expressionengine.com/forums/viewthread/168142/
进行解释;我有一系列条目,每个条目仅分配给一个类别。我想列出这些类别,并在每个类别下方列出带有其自定义字段之一的条目。像这样:
类别 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}
任何帮助都是非常感谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
所以,这就是我最后得到的结果(感谢 EE 委员会的一些帮助):
至于嵌入,它看起来像这样:
嵌入的原因与如何将事物拉入有关获得正确的频道条目;仅仅将
{exp:channel:entries}
内联到页面中并不太有效。So, here's what I ended up with at the end (courtesy of some help over at the EE boards):
And as for the embed, it looks like this:
The reason for the embed has to do with how things are pulled in with regards to getting the correct channel entries; simply having the
{exp:channel:entries}
inline in the page didn't quite work.类别存档标签可能对您有帮助:
http://ellislab.com /expressionengine/user-guide/modules/channel/category_archive.html
The Category Archive tag might be helpful to you:
http://ellislab.com/expressionengine/user-guide/modules/channel/category_archive.html
这可能是您所追求的一个非常基本的示例:
This may be a very basic example of what you're after: