Drupal 视图 - 自定义/修改 SQL

发布于 2024-10-17 15:58:38 字数 310 浏览 3 评论 0原文

我遇到了“配置文件复选框”模块的问题,该模块存储以逗号分隔的自定义配置文件字段。

问题是我是否创建一个视图来按值过滤。 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

哽咽笑 2024-10-24 15:58:38

对于“快速破解”解决方案,您可以尝试实现 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 ...

甜味超标? 2024-10-24 15:58:38

我是个人资料复选框的创建者和维护者,我认为您可能有兴趣知道新版本的该模块现在将值存储为序列化并包含视图支持。该功能在当前发行版本中可用。

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.

薄荷梦 2024-10-24 15:58:38

查看视图修改查询模块。

Check out the Views modify query module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文