举例如首页调用方法:
1、先打开index.php文件找到以下代码:
$smarty->assign('new_articles', index_get_new_articles()); // 最新文章
在它下面增加以下:
//调用方法
$smarty->assign('class_articles_4', index_get_class_articles(4,6)); // 分类调用文章
//调用多个就修改传进去的参数,以及模板接收的变量,其中上面的4就是文章分类ID,其中6是调用数量
$smarty->assign('class_articles_5', index_get_class_articles(5,6)); // 分类调用文章
$smarty->assign('class_articles_6', index_get_class_articles(6,6)); // 分类调用文章
$smarty->assign('class_articles_7', index_get_class_articles(7,6)); // 分类调用文章
$smarty->assign('class_articles_8', index_get_class_articles(8,6)); // 分类调用文章 //在最后?>这个之前增加以下函数 function index_get_class_articles($cat_aid, $cat_num)
{
$sql = "SELECT article_id, title,open_type,cat_id,file_url FROM " .$GLOBALS['ecs']->table('article'). " WHERE cat_id = ".$cat_aid." and is_open = 1 LIMIT " . $cat_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]['cat_name'] = $row['cat_name'];
$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']);
$arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']));
}
return $arr;
}
2、第二步是在index.dwt模板想调用的地方增加以下代码,(注:以下调上面设置里的分类ID为8的文章列表):
<!--{foreach from=$class_articles_8 item=article}-->
<li><a href="{$article.url}" title="{$article.title|escape:html}"><!--{$article.short_title|truncate:15:true}--></a></li>
<!--{/foreach}-->

ECShop怎么首页调用文章列表的更多相关文章

  1. dedecms织梦首页如何调用文章列表?

    如果冯耀宗博客类似,首页调用文章列表,同时也有许多企业站需要调用文章列表,今天我与大家来分享一下dedecms织梦首页如何调用文章列表? {dede:arclist     row='16'  tit ...

  2. dedecms利用addfields body在首页调用文章内容

    开源程序比较好的一点是可以进行二次开发,比如ytkah想要开发一个专家出诊表的功能模块,如下图所示,每天的专家都不一样,可以用到内容模型,但是相对比较复杂:我们可以把每天的坐诊情况写成一篇文章再通过调 ...

  3. dedecms调用文章列表第一篇和下面几篇不同的方法

    {dede:arclist row=1 orderby=pubdate infolen=60 limit=0,1} <li class="dot1"><img s ...

  4. 织梦CMS调用文章列表时,怎么显示短时间格式

    问题描述:织梦在上传文章的时候,默认的上传文章的时间格式都是年.月.日.小时.分钟.秒的格式,怎么才能实现仅显示年.月.日的格式呢? 解决方法: [field:pubdate function=&qu ...

  5. onethink封装arclist调用文章列表!

    其实没有什么东西,做个记录,方便以后使用! <ul> <arclist mid='2' cid='2' row='2'> <li>{$title}</li&g ...

  6. wordpress 首页调用文章 不同样式的方法

    <?php $count = 1; $display_categories = array(1); foreach ($display_categories as $category) { ?& ...

  7. PHPCMS V9 栏目列表调用文章点击量及评论数量方法

    很多朋友在用Phpcms做站时,具体需要在列表页.首页调用文章列表调用文章的点击量和评论排行,那么怎么才能做到在Phpcms v9首页.频道页.列表页.推荐位等页面获取文章浏览量和评论统计呢? 原因起 ...

  8. ecshop 不同页面调用不同分类文章的解决办法

    调用文章列表,需要修改对应的程序,修改index.php或者arctical_cat.php文件在$smarty->assign('new_articles', index_get_new_ar ...

  9. 【Android 我的博客APP】1.抓取博客首页文章列表内容——网页数据抓取

    打算做个自己在博客园的博客APP,首先要能访问首页获取数据获取首页的文章列表,第一步抓取博客首页文章列表内容的功能已实现,在小米2S上的效果图如下: 思路是:通过编写的工具类访问网页,获取页面源代码, ...

随机推荐

  1. 51nod 1218 最长递增子序列 V2——LIS+思路(套路)

    题目:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1218 自己怎么连这种 喜闻乐见的大水题 都做不出来了…… 好像见过 ...

  2. javascript getAttribute

    var nodes = document.getElementsByTagName("script"); var node = nodes[nodes.length - 1]; v ...

  3. POJ-3262

    Protecting the Flowers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7923   Accepted: ...

  4. Pseudo Random Nubmer Sampling

    Pseudo Random Nubmer Sampling https://en.wikipedia.org/wiki/Inverse\_transform\_sampling given a dis ...

  5. Java socket异常

    Java socket异常 分类: Java 2013-07-15 22:38 981人阅读 评论(0) 收藏 举报 目录(?)[+] 使用Java socket编写程序时,通常会遇到几种种异常:Bi ...

  6. 数据库路由中间件MyCat - 源代码篇(12)

    此文已由作者张镐薪授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. NodeList ruleNodes = e.getElementsByTagName("rule ...

  7. 洛谷 - P1631 - 序列合并 - 堆

    https://www.luogu.org/problemnew/show/P1631 序列a中每个数首先都和序列b中的最小元素配对(虽然好像不是很必要这么早插进来?) 每次从堆顶取出最小的和输出答案 ...

  8. U3D Shader基础

    http://blog.sina.com.cn/s/blog_471132920101dcnr.html 转载自风宇冲Unity3D教程学院 一个SubShader(渲染方案)是由一个个Pass块来执 ...

  9. python unittest模块

    import unittest import random class Operation(object): def __init__(self, num1=0, num2=0): if not (0 ...

  10. luogu 1169 棋盘制作(单调栈/悬线)

    luogu 1169 棋盘制作(单调栈/悬线) 国际象棋是世界上最古老的博弈游戏之一,和中国的围棋.象棋以及日本的将棋同享盛名.据说国际象棋起源于易经的思想,棋盘是一个8*8大小的黑白相间的方阵,对应 ...