ecsho实现多级分类方法(亲测)

小林2013-03-18SEO210

其实分类页面里面本来就有相关的品牌、属性、分类的筛选功能在category.php和模板加上相应的功能即可

1、读出当前分类的所有下级分类


  $chlidren_category = $GLOBALS['db']->getALl('SELECT cat_id,cat_name FROM ' . $GLOBALS['ecs']->table('category') ." WHERE parent_id = '$cat_id' and is_show=1");

  $category_id_all = array('all'=>array('cat_id'  => $cat_id,

                       'cat_name'    => 'all category',

                       'show'      =>1

                       )

                   );

   foreach($chlidren_category as $key=>$value)

   {

                   if($value['cat_id']==$cat_id)

                   {

                           $chlidren_category[$key]['show']=1;$category_id_all['show']=0;continue;

                           }

                           else $chlidren_category[$key]['show']=0;

           }

   $category_list = array_merge($category_id_all, $chlidren_category);

               $smarty->assign('category_list_all',    $category_list);


2、修改goods_list.lbi文件,  <form method="GET" name="listform">下面加入循环出分类的模板代码

        <!--&#123;foreach from=$category_list_all item=cat_list&#125;-->

        <a href="javascript:;" onClick="javascript:category_change(&#123;&#36;cat_list.cat_id&#125;)">&#123;&#36;cat_list.cat_name&#125;</a

        <!--{/foreach}-->


<input type="hidden" name="category" value="&#123;&#36;category&#125;" />改为
<input type="hidden" id="category_id" name="category" value="&#123;&#36;category&#125;" />

3、common.js中加入js脚本

function category_change(cat_id)

{

   document.getElementById('category_id').value = cat_id;

   setTimeout(doSubmit, 0);

   function doSubmit() {document.forms['listform'].submit();}

}


最终效果如下图:

ECSHOP分类页面筛选功能(按分类下子分类和品牌筛选) - labbs - 单纯枫部落阁




相关文章

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。