該功能主要用于在商品詳細頁面里的如:商品信息/規格參數/客戶評價/購買記錄/售后服務/常見問題;“售后服務/常見問題”就是文章的頁面內容,所以下面就是調用該頁面內容的數據方法:
第一:在goods.php里最尾部寫上方法,代碼如下:
/** 2012-08-03 作者:嚴微 * 獲得指定的文章的內容 * * @access private * @param integer $article_id * @return array */ function get_article($article_id) { /* 獲得文章的信息 */ $sql = 'SELECT article_id, title,content' . ' FROM ' .$GLOBALS['ecs']->table('article') . ' WHERE article_id='.$article_id; $row = $GLOBALS['db']->getRow($sql); return $row; }
然后在:
$smarty->assign('article',get_article(19)); //獲取文章的內容頁面 $smarty->assign('article1',get_article(20)); //獲取文章的內容頁面
其次在goods.dwt模板里輸出:
{$article.content} //對應ID=19的變量名article
{$article1.content}//對應ID=20的變量名article1
Copyright © 2009-2019 Ywcms.Com All Right Reserved. 湘ICP備16006489號-2