/**
* 獲得很新的文章列表。
*
* @access ?private
* @return ?array
*/
function index_get_new_articles()
{
$sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name ' .
' FROM ' . $GLOBALS['ecs']->table('article') . ' AS a, ' .
$GLOBALS['ecs']->table('article_cat') . ' AS ac' .
' WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_type = 1' .
' ORDER BY ?a.add_time DESC,a.article_type DESC ?LIMIT 11';
$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']), $row['cat_name']);
}
return $arr;
}
2.在增加:
$smarty->assign('new_articles', index_get_new_articles()); ? // 新文章-這個新文章
3.要顯示頁面地方增加:
-
{$smarty.foreach.name.iteration}
{$article.short_title}|truncate:18}
然后刷新看看效果吧! 版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: ecshop商城任意位置調(diào)用新文章的方法