表达式引擎sql查询条目作者列表 [英] expression engine sql query entries list by authors

查看:76
本文介绍了表达式引擎sql查询条目作者列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从一个作者那里订购一个频道中最新的3个条目? (因此,它们最终不会成为同一作者的3个最新条目)-我想我需要为此使用SQL查询吗?

How would I order the latest 3 entries from a channel with each entry from a different author? (so they don't end up being 3 latest entries by the same author) - I think I need to use an SQL Query for it?

{exp:channel:entries orderby="screen_name|date" channel="portfolios" limit="3" group_id="5" dynamic="no"}
<img src=" {thumbnail}" alt="{title}"/><br />
{title}<br />
{/exp:channel:entries} 

提前谢谢!

推荐答案

标记-这是我在这里最好的方法是,因为需要解析您的自定义字段,因此首先要查找来自不同作者的最新4个条目的entry_id,然后使用entry_id参数通过嵌入将它们传递给channel:entries标记.

The best approach here, since you need your custom fields parsed, is to first find the entry_ids of the latest 4 entries from distinct authors, and then pass those to the channel:entries tag through an embed using the entry_id parameter.

这应该起作用(确保将channel_id替换为适当的整数).替换当前的整个代码块:

This should work (be sure to replace the channel_id with the appropriate integer). Replace your entire current chunk of code with this:

{embed="embeds/_latest_per_member" entry_ids="{exp:query sql="SELECT entry_id, author_id FROM exp_channel_titles WHERE entry_date IN( SELECT MAX(entry_date) FROM exp_channel_titles  WHERE status != 'closed' AND channel_id = 1 GROUP BY author_id ) ORDER BY entry_date DESC LIMIT 4" backspace="1"}{entry_id}|{/exp:query}"}

然后您的 embeds/_latest_per_member 模板可以如下所示:

Then your embeds/_latest_per_member template can look something like this:

{exp:channel:entries channel="channel_name" entry_id="{embed:entry_ids}"}
    {author_id}<br />
    <a href="{path=portfolios/gallery/{username}}"><img src="{thumbnail}"></a><br>
    <a href="{path=portfolios/gallery/{username}}">{title}</a><br />
{/exp:channel:entries}

您已经提到,此代码给您递归错误-这意味着您已在嵌入内 再次调用了嵌入.不要那样做.

You had mentioned that this code gave you a recursive error - that means that you've put another call to the embed within the embed. Don't do that.

这篇关于表达式引擎sql查询条目作者列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆