Drupal Views - Custom / Modded SQL

2019-07-07 07:29发布

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?

3条回答
forever°为你锁心
2楼-- · 2019-07-07 07:49

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 ...

查看更多
倾城 Initia
3楼-- · 2019-07-07 08:05

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.

查看更多
Bombasti
4楼-- · 2019-07-07 08:05

Check out the Views modify query module.

查看更多
登录 后发表回答