在 ExpressionEngine 中显示每个类别的条目

发布于 2024-10-11 01:09:12 字数 1412 浏览 3 评论 0原文

因此,我进行了搜索,发现了一些帖子可以满足我的需求,但仍然不太有效。这篇文章似乎最接近我想要实现的目标,我根据它构建了我的代码: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

面如桃花 2024-10-18 01:09:13

所以,这就是我最后得到的结果(感谢 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} 内联到页面中并不太有效。

So, here's what I ended up with at the end (courtesy of some help over at the 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}

And as for the embed, 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 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.

末骤雨初歇 2024-10-18 01:09:12

这可能是您所追求的一个非常基本的示例:

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

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}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文