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?
推荐答案
对于quick hack解决方案,您可以尝试实现 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屋!