zoukankan      html  css  js  c++  java
  • 易企cms获取分类下的指定个数产品方法

    易企cms默认版本能获取指定分类的所有产品,但是不能获取指定的个数,为了能够获取指定的个数,我找到了GetProductList方法进行了改进:

    1.找到根目录下的include/product.class.php文件搜索关键字"GetProductList"将GetProductList方法替换为如下代码,

        function GetProductList($cid,$skip=0,$take=10,$orderby="adddate desc",$all=false)
        {
            global $yiqi_db;
            $categorydata = new Category();        
            $exist = $categorydata->ExistCategory($cid);
            if($exist == 1)
            {
                $cids = array($cid);
                $cids = array_merge($cids,$categorydata->GetSubCategoryIDs($cid));            
                $cids = implode(',', $cids);
                if($all)
                {
                    return $yiqi_db->get_results(CheckSql("select * from yiqi_product where cid in ($cids) order by $orderby limit $skip,$take "));
                }
                else
                {
                    return $yiqi_db->get_results(CheckSql(sprintf("select * from yiqi_product where cid in ($cids) and adddate <= '%s' order by $orderby limit $skip,$take",date("Y-m-d H:i:s"))));
                }
            }
            else
            {
                if($all)
                {
                    return $yiqi_db->get_results(CheckSql("select * from yiqi_product order by $orderby"));
                }
                else
                {
                    return $yiqi_db->get_results(CheckSql(sprintf("select * from yiqi_product where adddate <= '%s' order by $orderby",date("Y-m-d H:i:s"))));
                }
            }
        }
        

    2.模板文件中如何调用:

    {assign var="productlist" value=$productdata->GetProductList(3,0,5,"adddate desc")}
        {foreach from=$productlist item=subcateinfo}
           <li> 
             <a href="{formaturl type="product" siteurl=$siteurl name=$subcateinfo->filename}">{$subcateinfo->name}</a>
           </li>
     {/foreach}  
    GetProductList(3,0,5,"adddate desc")参数说明:GetProductList(分类id,跳跃个数,输出个数,"adddate desc")
    注:所有的标签函数都是可以修改的!
  • 相关阅读:
    C#中提供的精准测试程序运行时间的类Stopwatch
    [转]SQLite数据库扫盲
    [转]c# 使用ChartDirector绘图的一些个人体会
    [转]SQLite内存数据库
    SQL Server 各种查询语句执行返回结果
    [转]浅谈 BigInteger
    [转]SQLite数据库连接方式
    ASP.NET 3.5 开发大全DOC版
    好像昨天不见了100块钱。
    热烈庆祝本人昨天终于申请得了google ad
  • 原文地址:https://www.cnblogs.com/leeten/p/3805432.html
Copyright © 2011-2022 走看看