Q: 举个例子,我定义了几个字段:品牌,尺码,颜色然后我如何实现把这些字段变成过滤条件,如点击某个品牌时出来的内容都是字段内容里包含这个品牌的所有内容。
A:
Views 模块可以做过滤。 1,创建一个Content Type, 叫 Clothes 2,点击进去Clothes,增加三个字段: 名称:Size 类型: List(Text) 控件:select list,每行一个 名称:Brand 类型:List(Text) 控件:select list,每行一个 名称:Color 类型:List(Text) 控件 select list,每行一个 ![](http://www.drupalla.com/sites/default/files/styles/large/public/images/20122405103812.jpg)
3,新建一个views 叫 Clothes,Show 选 Content ,Type 选 clothes,按continue & edit ![](http://www.drupalla.com/sites/default/files/styles/large/public/images/20122405103947.jpg)
format 选table, field 里吧 Size, Brand, Color 加上 ![](http://www.drupalla.com/sites/default/files/styles/large/public/images/20122405104236.jpg)
增加FILTER CRITERIA,选择Size, Brand, Color, 在弹出的窗口中,找到Expose this filter to visitors, to allow them to change it, 勾上 ![](http://www.drupalla.com/sites/default/files/styles/large/public/images/20122405104710.jpg)
最终FILTER CRITERIA 列表如下: ![](http://www.drupalla.com/sites/default/files/styles/large/public/images/20122405104732.jpg)
好了,添加几个文章,打开 xxx.com/clothes 测试吧。 ![](http://www.drupalla.com/sites/default/files/styles/large/public/images/20122405105031.jpg)
本文选自:猪跑啦,谢谢!
|