ECSHOP首页调取固定的某个分类

商城的分类通常都很多,如果在网站首页全部调取,有时候会拉的很长。所以一直希望有一个可以调取固定某些分类的方法,今天终于找到了。

首先打开index.php

1、找到 $smarty->assign('shop_notice', $_CFG['shop_notice']); // 商店公告

在其后面添加(这里调取了两个分类为例)

 $smarty->assign('huacai',     get_cat_info(8));                // 获得子分类的信息
 $smarty->assign('yongtu',     get_cat_info(6));

2、找到

/**
 * 获得所有的友情链接
 *
 * @access  private
 * @return  array
 */

在其前面添加

/**
 * 获得分类的信息
 *
 * @param   integer $cat_id
 *
 * @return  void
 */
function get_cat_info($cat_id)
{
    $res = $GLOBALS['db']->getAll('Select c.cat_id, c.cat_name, r.recommend_type FROM ' . $GLOBALS['ecs']->table('category') . ' as c LEFT JOIN ' .  $GLOBALS['ecs']->table('cat_recommend') . ' as r ON c.cat_id = r.cat_id '.
        " Where parent_id = '$cat_id'");
 foreach ($res AS $k => $row)
    {
  $arr[$k]['cat_id'] = $row['cat_id'];
  $arr[$k]['cat_name'] = $row['cat_name'];
  $arr[$k]['recommend_type'] = $row['recommend_type'];
 }
 return $arr;
}

3、打开模板文件夹library,新建一个文件category_index.lbi

  <!--{foreach from=$huacai item=huacai}-->
   <a class="category_3tit" href="category.php?id={$huacai.cat_id}" <!--{if $huacai.recommend_type eq 3}--> class="red" <!--{/if}-->>{$huacai.cat_name}</a>|
  <!--{/foreach}-->
  <!--{foreach from=$yongtu item=yongtu}-->
   <a class="category_3tit" href="category.php?id={$yongtu.cat_id}" <!--{if $huacai.recommend_type eq 3}--> class="red" <!--{/if}-->>{$yongtu.cat_name}</a>|
  <!--{/foreach}-->

以上含义就是调取huacai代表分类id8和yongtu代表分类id6下的分类名称。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值