Views doesn't show checkbox fields where answer > 1

橙三吉。 提交于 2019-12-13 03:39:32

问题


I am using Drupal with Views and the extended profiles module activated. To enable users to check multiple areas of interest I also added a module called Profile Checkboxes. It adds the ability to use a free-form list but turns it into either check boxes or radio buttons.

This module works very cleanly and did not present errors. But if a user check multiple interests then those are stored in the profile_values table as a comma seperated value.

So if the user likes lets say cars, trucks and bikes. That is stored in one field of the database as:

+-----+-----+---------------------+
| fid | uid | value               |
+-----+-----+---------------------+ 
| 12  | 32  | cars, trucks, bikes |
+-----+-----+---------------------+

I want to be able to have views parse this correctly for me so that I can create filters that only shows users who have entered an interest. The options it gives me is to validate "if ant of" the values in the list is chose, I selected all the values in the list. But it only shows the users who have check one of the values. I hope it makes sense.

Do I need to code this in a custom tpl-file or can this be done with Views?


回答1:


You can do it with views, but in this case it will probably be a lot simpler to do it without views, unless you know the views API very well.




回答2:


Simple (and not so correct way) is using "Contain" filter for this "value" field in Views, so it will query like: value like '%trucks%'
Other way (but not so good): removing unfiltered datas in hooks of views after it get data and trying output: See .\sites\all\modules\views\docs\docs.php file about hooks.

p.s. Views + CCK + Content Profile, i think, will better.



来源:https://stackoverflow.com/questions/2328362/views-doesnt-show-checkbox-fields-where-answer-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!