Drupal 视图 - 自定义/修改 SQL
我遇到了“配置文件复选框”模块的问题,该模块存储以逗号分隔的自定义配置文件字段。
问题是我是否创建一个视图来按值过滤。 SQL 结果最终是这样的:
...AND (profile_values_profile_interests.value in ('Business and Investment'))...
它将不会返回任何数据,因为值是这样存储的:
“商业和投资、判例法、劳动法、税法”
我只需要调整 SQL,使其成为确保该字段包含所选值
我可以做些什么来调整它吗?
I am having an issue with the "Profile Checkboxes" module which stores custom profile fields comma separated.
The issue is if I create a view to filter by a value. The SQL result ends up being something like this:
...AND (profile_values_profile_interests.value in ('Business and Investment'))...
Which will not return any data since the value is stored like this:
"Business and Investment, Case Law, Labor Law, Tax Law"
I just need to adjust the SQL so that it is making sure the field contains the selected value
Is there anything I can do to adjust this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于“快速破解”解决方案,您可以尝试实现
hook_views_query_alter(&$view, &$query)
在自定义模块中,检查 $view->name (最终也检查 $view->name) current_display) 以确保您正在处理正确的视图/显示,然后根据需要操作 $query。编辑:看起来模块维护者同时已经解决了潜在的问题 - 查看约翰的回答 ...
For a 'quick hack' solution, you could try implementing
hook_views_query_alter(&$view, &$query)
in a custom module, check $view->name (and eventually also $view->current_display) to ensure you are dealing with the right view/display, and then manipulate $query as needed.EDIT: Looks like the underlying problem has been addressed by the module maintainer in the meantime - see John's answer ...
我是个人资料复选框的创建者和维护者,我认为您可能有兴趣知道新版本的该模块现在将值存储为序列化并包含视图支持。该功能在当前发行版本中可用。
I'm the creator and maintainer of Profile Checkboxes and thought you might be interested to know that the new version of the module now stores the values as serialized and includes Views support. The feature is available in the current release version.
查看视图修改查询模块。
Check out the Views modify query module.