您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程

ecshop调用指定dedecms织梦栏目文章列表

幼翠2023-12-12Ecshop商城教程已有人查阅

导读系统:dedecms + ecshop   实现步骤: 1.在文章模版goods.dwt添加一个新的库文件dede_articles.lbi themes/default/goods.dwt

系统:dedecms + ecshop   实现步骤: 1.在文章模版goods.dwt添加一个新的库文件dede_articles.lbi themes/default/goods.dwt,请根据你的目录结构修改,如果是首页,请在index.php中添加,栏目页在category.php中添加
<!-- #BeginLibraryItem "/library/dede_articles.lbi" --><!-- #EndLibraryItem -->
2.themes/default/library/dede_articles.lbi
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- {if $dede_articles} -->
<div class="h3Title"><h3>相关资讯</h3></div>
<ul class="brandList">
<!-- {foreach from=$dede_articles item=article} -->
<li><a href="{$article.url}" title="{$article.title}" rel="external">{$article.short_title|escape:html}
</a> </li>
<!-- {/foreach} -->
</ul>
<!-- {/if} -->
3.goods.php载入dede,请根据你的目录结构修改,如果是首页,请在index.php中添加,栏目页在category.php中添加。
define('IN_ECS', true);
/*载入dede*/
require_once(dirname(__FILE__)."/luxury/include/common.inc.php");
4.goods.php调用dede数据,如果是首页,请在index.php中添加,栏目页在category.php中添加
$smarty->assign('dede_articles', get_dede_articles()); //dede文章列表
5.get_dede_articles函数简单实现,如果是首页,请在index.php中添加,栏目页在category.php中添加。
/**
*
* 获取dedecms的文章
* @author http://www.heui.org
* @return 文章列表
*/
function get_dede_articles() {  //文档排序的方式
$orderby = 'rand';
$ordersql = '';
if($orderby=='hot' || $orderby=='click') $ordersql = " ORDER BY arc.click $orderWay";
else if($orderby == 'sortrank' || $orderby=='pubdate') $ordersql = " ORDER BY arc.sortrank $orderWay";
else if($orderby == 'id') $ordersql = "  ORDER BY arc.id $orderWay";
else if($orderby == 'near') $ordersql = " ORDER BY ABS(arc.id - ".$arcid.")";
else if($orderby == 'lastpost') $ordersql = "  ORDER BY arc.lastpost $orderWay";
else if($orderby == 'scores') $ordersql = "  ORDER BY arc.scores $orderWay";
else if($orderby == 'rand') $ordersql = "  ORDER BY rand()";
else $ordersql = " ORDER BY arc.sortrank $orderWay";
//limit条件
$line = 10;
$limit = trim(preg_replace('#limit#is', '', $limit));
if($limit!='') $limitsql = " LIMIT $limit ";
else $limitsql = " LIMIT 0,$line ";
$orwhere = '';
if(isset($orwheres[0])) {
$orwhere = join(' And ',$orwheres);
$orwhere = preg_replace("#^ And#is", '', $orwhere);
$orwhere = preg_replace("#And[ ]{1,}And#is", 'And ', $orwhere);
}
if($orwhere!='') $orwhere = " WHERE $orwhere ";
$addfieldsSql = '';
$addfieldsSqlJoin = '';
$sql =  "SELECT          arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,
tp.moresite,tp.siteurl,tp.sitepath
$addfieldsSql
FROM `dede_archives` arc left join `dede_arctype` tp on arc.typeid=tp.id
$addfieldsSqlJoin
$orwhere $ordersql $limitsql";
$res = $GLOBALS['db']->query($sql);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
$row['url'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
$row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row
['moresite'],$row['siteurl'],$row['sitepath']);
$row['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ?
sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
$arr[] = $row;
}
return $arr;
}
总结:最主要是需要实现获取文章路径, 在这个案例中我们载入dede, 直接调用GetFileUrl提示:把$orwhere = '';改为$orwhere = 'arc.typeid=1';//表示调用栏目ID为1的文章列表 $line = 10;//返回记录数

本文标签:

很赞哦! ()

相关源码

  • (自适应)幽默笑话脑筋急转弯搞笑趣图博客pbootcms模板下载本模板基于PbootCMS系统开发,专为幽默笑话、搞笑趣图类网站设计。采用轻松活泼的布局风格,突出娱乐内容分享特色,适合各类笑话、段子、搞笑图片等内容展示。查看源码
  • (PC+WAP)蓝色新能源环保太阳能光伏模板pbootcms下载新能源环保行业网站解决方案为太阳能光伏系统企业打造的专业网站模板,助力新能源企业高效展示产品与服务PbootCMS内核开发,源码开放可修改PC与手机端自适应设计查看源码
  • (自适应)驾校培训学车活动免费pbootcms源码下载本模板基于PbootCMS内核开发,为驾校培训行业打造,具备完善的招生展示、课程预约、教练团队展示等功能模块。响应式设计适配各类移动终端,数据实时同步管理,助您高效开展线上业务。查看源码
  • (自适应响应式)超市仓储仓库货架展架网站pbootcms源码下载本模板为货架展架、仓储货架行业量身打造,采用PbootCMS内核开发,充分考虑了货架产品展示和企业形象展示的需求。模板设计简洁大方,突出产品特点,能够有效展示各类货架产品的规格参数和应用场景,帮助访客快速了解企业核心业务和产品优势。查看源码
  • (自适应)游泳馆泳池水处理器设备pbootcms网站模板免费下载专注服务于泳池水处理设备制造商、泳池系统工程商等企业用户。模板预设设备分类体系、技术参数展示模块和解决方案呈现页面,满足行业特有展示需求。查看源码
  • (自适应)英文电子芯片电子元件网站pbootcms模板下载基于PbootCMS内核开发的电子元件类企业专用模板,采用响应式设计技术,适配电子元器件、集成电路、半导体等行业的品牌展示与技术文档发布需求。前端布局针对芯片参数表格与产品规格书展示进行深度优化。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐