表达式引擎orderby问题

发布于 2024-12-12 07:30:18 字数 625 浏览 0 评论 0原文

您好,我正在尝试按姓氏字段对条目进行排序,但它似乎不起作用。将 orderby 和 sort 更改为任何内容都会给出相同的结果 - 最新条目位于列表的最后。

有什么想法我可能做错了什么吗?

{exp:query sql="SELECT member_id FROM exp_members WHERE group_id = '5'"}
{exp:member:custom_profile_data  member_id="{member_id}" orderby="surname" sort="asc"}
<li><a href="{path=portfolios/gallery/{username}}"><img src="{photo_url}" width="138" height="103" alt="{screen_name}" /></a>
<h3 class="name"><a href="{path=portfolios/gallery2/{username}}">{firstname} {surname}</a></h3></li>
{/exp:member:custom_profile_data} 
{/exp:query} 

Hi I’m trying to order entries by a field called surname but it just doesn’t seem to be working. changing orderby and sort to anything gives the same results - latest entry last in list.

Any ideas what I could be doing wrong?

{exp:query sql="SELECT member_id FROM exp_members WHERE group_id = '5'"}
{exp:member:custom_profile_data  member_id="{member_id}" orderby="surname" sort="asc"}
<li><a href="{path=portfolios/gallery/{username}}"><img src="{photo_url}" width="138" height="103" alt="{screen_name}" /></a>
<h3 class="name"><a href="{path=portfolios/gallery2/{username}}">{firstname} {surname}</a></h3></li>
{/exp:member:custom_profile_data} 
{/exp:query} 

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

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

发布评论

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

评论(2

柒七 2024-12-19 07:30:18

为了节省一些精力,您可能需要考虑在您的网站上使用 Exp-resso 的 Freemember。 https://github.com/expressodev/freemember

该模块具有超级简单的语法来完成您想要的操作并且可能会添加一些附加功能以使您的 ExpressionEngine 开发更容易。

To save yourself some energy you might want to think about using Freemember from Exp-resso on your site. https://github.com/expressodev/freemember

This module has super simple syntax to do what you are wanting and might add some additional features to make your ExpressionEngine development easier.

凉风有信 2024-12-19 07:30:18

我首先要指出的是,如果您有很多成员,这个嵌套查询可能真的会导致您的服务器陷入困境。使用查询模块一次性获取所有会员数据,然后在没有嵌套 custom_profile_data 标记的情况下对其进行交互,效率会更高。您必须考虑使用 custom_profile_data 预先操作的变量(例如图像 URL),但在性能提升方面付出的努力是值得的。

无论如何:

custom_profile_data 标记仅查询单个成员,因此 orderbysort 不会产生任何区别。您的排序需要在 exp:query 标记期间进行。

{exp:query sql="SELECT m.member_id FROM exp_members m, exp_member_data d WHERE m.group_id = '5' AND d.member_id = m.member_id ORDER BY d.m_field_id_X ASC"}
{exp:member:custom_profile_data  member_id="{member_id}"}
    <li><a href="{path=portfolios/gallery/{username}}"><img src="{photo_url}" width="138" height="103" alt="{screen_name}" /></a>
    <h3 class="name"><a href="{path=portfolios/gallery2/{username}}">{firstname} {surname}</a></h3>
    </li>
{/exp:member:custom_profile_data} 
{/exp:query}

m_field_id_X 替换为您的 surname 自定义成员字段的实际 m_field_id(可以通过查看 exp_member_fields 找到该字段) 工具 → 数据 → SQL 管理器)。

I'll start by pointing out that if you have a lot of members, this nested query could really bog down your server. It would be much more efficient to use the Query module to get all of your member data in one go, then interate through it without the nested custom_profile_data tag. You'd have to account for variables that get manipulated beforehand using custom_profile_data (like image URLs), but it would be worth the effort in performance gains.

Regardless:

The custom_profile_data tag only queries a single member, so orderby and sort won't make any difference. Your sorting needs to take place during your exp:query tag.

{exp:query sql="SELECT m.member_id FROM exp_members m, exp_member_data d WHERE m.group_id = '5' AND d.member_id = m.member_id ORDER BY d.m_field_id_X ASC"}
{exp:member:custom_profile_data  member_id="{member_id}"}
    <li><a href="{path=portfolios/gallery/{username}}"><img src="{photo_url}" width="138" height="103" alt="{screen_name}" /></a>
    <h3 class="name"><a href="{path=portfolios/gallery2/{username}}">{firstname} {surname}</a></h3>
    </li>
{/exp:member:custom_profile_data} 
{/exp:query}

Replace m_field_id_X with the actual m_field_id of your surname custom member field (which can be found by looking at exp_member_fields in Tools → Data → SQL Manager).

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