ExpressionEngine:按相关条目对频道列表进行排序

发布于 2024-12-02 04:38:15 字数 559 浏览 1 评论 0原文

有人可以帮我按相关条目标题对频道列表进行排序吗?

我有一个频道“teams”,其中有一个字段 team_region,该字段依赖于另一个频道“regions”。

我的代码如下:

 {exp:channel:entries channel="teams" orderby="" sort="asc" limit="10"}
    <tr>
          <td>{title}</td>
          <td>{team_address}</td>
          <td>{related_entries id="team_region"}{title}{/related_entries}</td>
    </tr>
 {/exp:channel:entries}

我想按“team_region>>”对结果进行排序标题'。有可能实现这一目标吗?

谢谢你!

Can someone help me in sorting a channel listing by Related entry title please?

I have a channel 'teams' which has a field team_region which depends on another channel 'regions'.

My code is as follows:

 {exp:channel:entries channel="teams" orderby="" sort="asc" limit="10"}
    <tr>
          <td>{title}</td>
          <td>{team_address}</td>
          <td>{related_entries id="team_region"}{title}{/related_entries}</td>
    </tr>
 {/exp:channel:entries}

I want to Sort the result by 'team_region >> title'. Is it possible to achieve this?

Thank You!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

青瓷清茶倾城歌 2024-12-09 04:38:15

为什么不采取相反的方法 - 从“区域”频道开始,然后使用反向相关条目 列出您的团队。添加一个查询标记以从 {reverse_lated_entries} 循环中获取区域的标题,然后您就可以开始了:

{exp:channel:entries channel="regions" orderby="title" sort="asc"}
{reverse_related_entries orderby="title" sort="asc" channel="teams"}
    <tr>
        <td>{title}</td>
        <td>{team_address}</td>
        <td>{exp:query sql="SELECT title as region_title FROM exp_channel_titles t LEFT JOIN exp_relationships r ON r.rel_child_id = t.entry_id WHERE r.rel_id = {team_region} LIMIT 1"}{region_title}{/exp:query}</td>
    </tr>
{/reverse_related_entries}
{/exp:channel:entries}

Why not take the opposite approach - start with the Regions channel, then use reverse related entries to list your teams. Add a query tag to grab the region's title from within the {reverse_related_entries} loop, and you should be good to go:

{exp:channel:entries channel="regions" orderby="title" sort="asc"}
{reverse_related_entries orderby="title" sort="asc" channel="teams"}
    <tr>
        <td>{title}</td>
        <td>{team_address}</td>
        <td>{exp:query sql="SELECT title as region_title FROM exp_channel_titles t LEFT JOIN exp_relationships r ON r.rel_child_id = t.entry_id WHERE r.rel_id = {team_region} LIMIT 1"}{region_title}{/exp:query}</td>
    </tr>
{/reverse_related_entries}
{/exp:channel:entries}
柠檬 2024-12-09 04:38:15

您可能想查看 Pixel 和 Tonic 的 Playa。它是一个强大的多关系工具,比内置关系字段有更多的选项。

您可能想要使用类似

{exp:playa:parents channel="channelname" orderby="title"}

链接到文档 →

You might want to look at Playa from Pixel and Tonic. It's a powerful multi-relational tool with tons more options than the built-in relationships field.

You'll probably want to use something like

{exp:playa:parents channel="channelname" orderby="title"}

Link to docs →

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