ecmall挂件 商品分类 + 分类下品牌 gcategory_brand_list
转载自:ecmall挂件 商品分类 + 分类下品牌 gcategory_brand_list
在gcategory_list挂件基础上修改的一个挂件,增加了展示分类下品牌,品牌显示个数可配置
widget.info.php
123456789101112<?phpreturnarray(?'name'????? => 'gcategory_brand_list',?'display_name'? => '商品分类 + 分类下品牌',?'author'??? => 'Heui',?'website'?? => 'http://www.heui.org',?'version'?? => '1.0',?'desc'????? => '展示第一第二级商品分类和一级分类下品牌,适合放在比较宽的区域',?'configurable'? => true,);??>
main.widget.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485<?php?/**?* 商品分类挂件?*?* @return? array?? $category_brand_list?*/classGcategory_brand_listWidget extendsBaseWidget{????var$_name= 'gcategory_brand_list';????var$_ttl? = 86400;?????function_get_data()????{????????$this->options['amount_cate'] = intval($this->options['amount_cate']);????????$this->options['amount_brand'] = intval($this->options['amount_brand']);?????????$cache_server=& cache_server();????????$key= $this->_get_cache_id();????????$data= $cache_server->get($key);????????if($data=== false)????????{????????????$gcategory_mod=& bm('gcategory', array('_store_id'=> 0));????????????$gcategories= array();????????????if(empty($this->options['amount_cate']))????????????{????????????????$gcategories= $gcategory_mod->get_list(-1, true);????????????}????????????else????????????{????????????????$gcategory= $gcategory_mod->get_list(0, true);????????????????$gcategories= $gcategory;????????????????foreach($gcategoryas$val)????????????????{????????????????????$result= $gcategory_mod->get_list($val['cate_id'], true);????????????????????$result= array_slice($result, 0, $this->options['amount_cate']);????????????????????$gcategories= array_merge($gcategories, $result);????????????????}????????????}????????????import('tree.lib');????????????$tree= newTree();????????????$tree->setTree($gcategories, 'cate_id', 'parent_id', 'cate_name');?????????????$data= $tree->getArrayList(0);????????????$cache_server->set($key, $data, $this->_ttl);????????}/////////////新增加的品牌分类////echo $this->options['amount_brand'];exit;?????????$good_mod=& m('goods');?????????foreach($dataas$key=> &$val){????????????$result= $good_mod->get_list(????????????????????????array('conditions'=> "cate_id_1 = ".$val['id'],????????????));?????????????foreach($resultas$key=> $value)? {????????????????if(!empty($value['brand'])){????????????????????$val['brand'][$key] = $value['brand'];????????????????}????????????}?????????????if(!is_null($val['brand'])){????????????????$val['brand'] = array_unique($val['brand']);????????????????if(!empty($this->options['amount_brand'])) {????????????????????$val['brand'] = array_slice($val['brand'], 0, $this->options['amount_brand']);;????????????????}????????????}else{????????????????$val['brand'] = null;????????????}????????}/////////////////????????return$data;????}?????functionparse_config($input)????{????????$result= array();????????$result['amount_cate'] = $input['amount_cate'];????????$result['amount_brand'] = $input['amount_brand'];????????return$result;????}}??>ecmall挂件下载:
gcategory_brand_list
This entry was posted in php and tagged ecmall