视图不显示答案 > 的复选框字段1
我正在使用 Drupal 并激活了视图和扩展配置文件模块。为了使用户能够检查多个感兴趣的领域,我还添加了一个名为个人资料复选框的模块。它增加了使用自由格式列表的能力,但将其转换为复选框或单选按钮。
该模块工作非常干净,没有出现错误。但是,如果用户检查多个兴趣,那么这些兴趣将以逗号分隔值的形式存储在 profile_values
表中。
因此,如果用户喜欢汽车、卡车和自行车。它存储在数据库的一个字段中,如下所示:
+-----+-----+---------------------+
| fid | uid | value |
+-----+-----+---------------------+
| 12 | 32 | cars, trucks, bikes |
+-----+-----+---------------------+
我希望能够让视图为我正确解析此内容,以便我可以创建仅显示已输入兴趣的用户的过滤器。它给我的选项是验证“如果”列表中的值被选择,我选择了列表中的所有值。但它只显示检查了其中一项值的用户。 我希望这是有道理的。
我是否需要在自定义 tpl 文件中对此进行编码,或者可以使用视图来完成吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用视图来完成此操作,但在这种情况下,不使用视图可能会更简单,除非您非常了解视图 API。
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.
简单(不是那么正确的方法)是在视图中对这个“值”字段使用“包含”过滤器,因此它将查询:值如'%trucks%'
其他方式(但不太好):在获取数据并尝试输出后删除视图挂钩中未过滤的数据:请参阅有关挂钩的 .\sites\all\modules\views\docs\docs.php 文件。
ps Views + CCK + Content Profile,我想,会更好。
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.