Drupal视图 - 自定义/修改SQL [英] Drupal Views - Custom / Modded SQL

查看:128
本文介绍了Drupal视图 - 自定义/修改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)< / code> ,检查$ 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.

EDIT:看起来模块维护人员已经解决了底层问题 - 见约翰的回答 ...

Looks like the underlying problem has been addressed by the module maintainer in the meantime - see John's answer ...

这篇关于Drupal视图 - 自定义/修改SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆