zoukankan      html  css  js  c++  java
  • 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下的分类名称。

  • 相关阅读:
    专访京东孙海波:大牛架构师养成记及电商供应链中区块链技术的应用(转)
    Python3 使用 matplotlib 画折线图
    JavaSE(十)之Map总结 (转)
    SciPy 安装不上?
    AI 也开源:50 大开源 AI 项目 (转)
    RabbitMQ的应用场景以及基本原理介绍 【转】
    mysql的水平拆分和垂直拆分 (转)
    MySQL在线大表DDL操作 (转)
    如何在原生工程中引入Cordova工程-for iOS 【转】
    Android 与 js 简单互调
  • 原文地址:https://www.cnblogs.com/wangblognet/p/2745883.html
Copyright © 2011-2022 走看看