在 Drupal 中公开视图过滤器
我在 CCK 字段上有一个名为“Region”的过滤器,我已经用下拉框公开了它,
我想要的是将其用作“Order By”功能,这样如果用户选择一个区域,它将对输出进行排序,首先显示选定的区域。
这样,如果给定区域中没有内容,它至少会显示其他区域的内容。
I have a filter on a CCK field called "Region", I have exposed it with a drop down box
What I want to happen is to use this as an "Order By" functionality, so that if the user selects a region, it will order the output with the selected region showing first.
This is so that if there is no content in a given region, it will at least display content from the other regions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法使用视图界面来执行此操作。目前只能向用户公开过滤器,而不能公开排序。因此,可以仅显示具有用户选择的特定原因的节点,而不对其进行排序。
您可以使用
hook_views_query_alter
在自定义模块中创建此功能。但它需要一些 php 编码,并且可能会有点棘手。You can't do this using the views interface. It's currently only possible to expose filters to users, not the sorting. So it's possible only to show nodes with a specific reason that the user choose, but not sort it.
You can create this functionality in a custom module using
hook_views_query_alter
. But it would require some php coding and would probably be a bit tricky to get right.