table('article'). " WHERE" />
1227浏覽量

ecshop如何根據分(fēn)類id調用文章

來源: 時間:2014-01-29
1、打開(kāi)includes下(xià) init.php
末尾處增加下(xià)列代碼——可根據實際情況,增删裏面的查詢字段。
function index_get_class_articles($cat_aid, $cat_num)
{
$sql = "SELECT article_id, title,open_type,cat_id,content,file_url,add_time,description 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]['content'] = $row['content'];
$arr[$idx]['short_content'] = sub_str($row['content'],33);
$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']));
$arr[$idx]['file_url']    = trim($row['file_url']);            //圖片路徑
$arr[$idx]['description']    = $row['description'];
$arr[$idx]['short_description']    = sub_str($row['description'],15);
}
return $arr;
}
 
2、在調用該文章的頁面添加代碼
 assign('articles',index_get_class_articles(14, 6));               
 ?>

聯系我(wǒ)們

一(yī)次需求提交或許正是成就一(yī)個出色産品的開(kāi)始。
歡迎填寫表格或發送合作郵件至: qczsky@126.com

大(dà)理青橙科技

電(diàn)話(huà):13988578755 13988578755

郵箱:qczsky@126.com

地址:大(dà)理市下(xià)關龍都春天10層