Drupal 视图 - 自定义/修改的 SQL [英] Drupal Views - Custom / Modded SQL
问题描述
我遇到了存储自定义配置文件字段逗号分隔的配置文件复选框"模块的问题.
I am having an issue with the "Profile Checkboxes" module which stores custom profile fields comma separated.
问题是我是否创建了一个视图来按值过滤.SQL 结果最终是这样的:
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"
我只需要调整 SQL 以确保该字段包含所选值
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?
推荐答案
对于快速破解"解决方案,您可以尝试实施 hook_views_query_alter(&$view, &$query)
在自定义模块中,检查 $view->name(最终还有 $view->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.
看起来模块维护者同时解决了潜在的问题 - 看约翰的回答 ...
Looks like the underlying problem has been addressed by the module maintainer in the meantime - see John's answer ...
这篇关于Drupal 视图 - 自定义/修改的 SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!