表达式引擎orderby问题
您好,我正在尝试按姓氏字段对条目进行排序,但它似乎不起作用。将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了节省一些精力,您可能需要考虑在您的网站上使用 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.
我首先要指出的是,如果您有很多成员,这个嵌套查询可能真的会导致您的服务器陷入困境。使用查询模块一次性获取所有会员数据,然后在没有嵌套
custom_profile_data
标记的情况下对其进行交互,效率会更高。您必须考虑使用custom_profile_data
预先操作的变量(例如图像 URL),但在性能提升方面付出的努力是值得的。无论如何:
custom_profile_data
标记仅查询单个成员,因此 orderby 和 sort 不会产生任何区别。您的排序需要在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 usingcustom_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 yourexp:query
tag.Replace
m_field_id_X
with the actualm_field_id
of yoursurname
custom member field (which can be found by looking atexp_member_fields
in Tools → Data → SQL Manager).