内容正在载入中,请稍后……
公告
About me
其他
音乐播放器
日历
支持我的AD
统计
28 Jun.2009

如何修改ECSHOP首页或其他页面的商品展示数量 不指定

作者: 我就是个世界   分类:技术&学习 » PHP 学习   出处:本站原创            | |
收藏到网摘:收藏到QQ书签 搜狐网摘 百度搜藏 Google书签 Del.icio.us Yahoo收藏 新浪ViVi收藏夹 365天天网摘 天极网摘 我摘·网摘·网络书签 POCO网摘 YouNote网摘 和讯网摘 Bolaa博拉博客收录中心 igooi网摘 天下图摘
      这两天很忙,没什么时间,前天匆匆忙忙帮朋友用ECSHOP做了个爱之缘成人用品网上商店,因为他要急着用。就这样交给他用了。
今天问我为什么首页总是显示3个商品,不能多点? 我说这个应该没问题的吧,帮他去后台看了一下,记得发布商品的时候可以直接在商品列表处选择是否是新品、精品和热销的,但我去设置了,首页还是没有显示,奇了怪了,自认为人家官方不可能把这个设置到模版里那么不智能的吧,可是在商店设置里找了半天也没找到在哪里设置,到模版设置里又找了一下还是没看见。于是开始翻程序代码:

找到根目录/includes/lib_main.php找到函数:get_library_number

/**  
* 取得某模板某库设置的数量  
* @param   string      $template   模板名,如index  
* @param   string      $library    库名,如recommend_best  
* @param   int         $def_num    默认数量:如果没有设置模板,显示的数量  
* @return  int         数量  
*/  
function get_library_number($library, $template = null)  
{  
    if (emptyempty($template))  
    {  
        $template = basename(PHP_SELF);  
        $template = substr($template, 0, strrpos($template, '.'));  
    }  
    $template = addslashes($template);  
  
    static $lib_list = array();  
  
    /* 如果没有该模板的信息,取得该模板的信息 */  
    if (!isset($lib_list[$template]))  
    {  
        $lib_list[$template] = array();  
        $sql = "SELECT library, number FROM " . $GLOBALS['ecs']->table('template') .  
                " WHERE theme = '" . $GLOBALS['_CFG']['template'] . "'" .  
                " AND filename = '$template' AND remarks='' ";  
          
        $res = $GLOBALS['db']->query($sql);  
        while ($row = $GLOBALS['db']->fetchRow($res))  
        {  
            $lib = basename(strtolower(substr($row['library'], 0, strpos($row['library'], '.'))));  
            $lib_list[$template][$lib] = $row['number'];  
        }  
    }  
  
    $num = 0;  
    if (isset($lib_list[$template][$library]))  
    {  
        $num = intval($lib_list[$template][$library]);  
    }  
    else  
    {  
        /* 模板设置文件查找默认值 */  
        include_once(ROOT_PATH . 'admin/includes/lib_template.php');  
        static $static_page_libs = null;  
        if ($static_page_libs == null)  
        {  
            $static_page_libs = $page_libs;  
        }  
        $lib = '/library/' . $library . '.lbi';  
  
        $num = isset($static_page_libs[$template][$lib]) ? $static_page_libs[$template][$lib] :  3;  
    }  
  
    return $num;  
}  


我们可以看到,他是把从数据库里的所有商品数据列出来之后在用get_library_number函数来切割数组的(array_slice)。这里的处理是从数据库里列出模板的lib。打印出sql看到(echo $sql)

SELECT library, number FROM `ec`.`ecs_template` WHERE theme = 'default' AND filename = 'index' AND remarks=''  


其搜索结果为:

Highslide JS



哈哈。到这里应该不用在多说什么了吧?哈哈

直接修改相应的lib文件就可以了。。

这里以修改最新商品展示数量为例:

打开管理后台->模板管理->设置模板->新品上架->显示数量

看到这里才会恍然大悟,原来都在这里设置,都怪自己没注意看。

说了一堆代码。到后台改改就行了。
时间:14:52 评论(0) 引用(0) 阅读(407) Tags: , , ,
发表评论
  昵称 [注册]
  密码 (游客无需密码)
  网址
  电邮
OpenID登入 权限选项 表情