百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>Ecshop教程> ecshop调取文章可做成文章频道调取文章可按倒序正序同时可以设定
分享文章到:

ecshop调取文章可做成文章频道调取文章可按倒序正序同时可以设定

发布时间:08/01 来源:未知 浏览: 关键词:
ecshop调取文章,ecshop商城任何页面可以调取指定文章分类下面文章,同时可以操纵文章倒序正序乃至文章数目。 同时可以独自做成文章频道,比方我们复制一个index.php,改名wenzhan.php 在创建立 wenzhan.dwt文件,和wenzhan.lbi 。 先说说怎样调取指定文章分类下面文章,然后wenzhan.php文章频道调取不一样文章分类文章 文章频道结果:点击查看ECSHOP文章频道 调取不一样分类文章组成一个文章频道页面
本案例按index.php 讲解:
1. 在任何页面php页面比方(index.php    goods.php)下面 ?>增添  


/*------------------------------------------------------ */
//-- PRIVATE FUNCTIONS
/*------------------------------------------------------ */
function index_get_class_list_articles($cat_id='0',$list_type='0',$list_num='10',$list_order='add_time DESC'){
    $cat_str = get_article_children($cat_id);
    $sql = 'SELECT article_id, title, add_time, file_url, open_type ' .
        ' FROM ' . $GLOBALS['ecs']->table('article') . ' WHERE ' ;
    if($cat_id!='0'){
        $sql =$sql.$cat_str." and " ;
    }
    $sql =$sql.' article_type='.$list_type .' ORDER BY '.$list_order.' LIMIT ' . $list_num;
    $res = $GLOBALS['db']->getAll($sql);
    $arr = array();
    foreach ($res AS $idx => $row)
    {
        $arr[$idx]['id']          = $row['article_id'];
        $arr[$idx]['title']       = $row['title'];
        $arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ?
            sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
        $arr[$idx]['add_time']    = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
        $arr[$idx]['url']         = $row['open_type'] != 1 ?
            build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
    }
    return $arr;
}



2.  在index.php   $smarty->assign('hot_goods',       get_recommend_goods('hot'));     // 热点文章 下面增添 $smarty->assign('list_articles13',  index_get_class_list_articles('13','0','9','add_time DESC'));
//13为文章分类ID,别告诉我你不知道如何看;0代表一般的文章;9是文章显示数目;add_time (DESC倒序,ASC正序


3.index.dwt增添下面代码: 13代表文章分类ID <!--{foreach from=$list_articles13 item=article}-->
<li><a title="{$article.title|escape:html}" href="{$article.url}">{$article.title}</a></li>
<!--{/foreach}-->





4.$smarty->assign('list_articles13',  index_get_class_list_articles('13','0','9','add_time DESC'));
//13为文章分类ID,别告诉我你不知道如何看;0代表一般的文章;9是文章显示数目;add_time (DESC倒序,ASC正序
假如吧:DESC改成ASC $smarty->assign('list_articles13',  index_get_class_list_articles('13','0','9','add_time ASC'));
那么前台排序就不一样了如图: 看前台:


打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有152人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板