Views doesn't show checkbox fields where answe

2019-09-02 18:26发布

问题:

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.