小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

如何在ECShop首頁調(diào)用評論

 quasiceo 2014-05-03

    ECShop的評論,其實和留言板是在一起的,大家訪問自己的留言板就可以發(fā)現(xiàn)這個問題。

現(xiàn)在我們只需要把message.php的內(nèi)容調(diào)用到首頁顯示即可。在ECShop官方論壇實際上已經(jīng)提到了一些。

 

第1步,在index.php的最后添加一個函數(shù):

function index_get_comments()
{
$sql = 'SELECT id_value, user_name, content, add_time FROM ' . $GLOBALS['ecs']->table('comment') . ' WHERE comment_rank = 5 AND status = 1 ORDER BY comment_id DESC LIMIT 5';
$res = $GLOBALS['db']->getAll($sql);
$pvnewcomments = array();
foreach ($res AS $row)
{
$pvnewcomments[] = array('id_value' => $row['id_value'],
'user_name'  => $row['user_name'],
'content'  => $row['content'],
'add_time' => date("Y-m-d H:i:s", $row['add_time']));
}
return $pvnewcomments;
}

 

第2步,在index.php中很多$smarty->assign那段添加一行:

$smarty->assign('pvnewcomments', index_get_comments());

 

第3步,在模板index.dwt中要調(diào)用最新評論的位置添加以下代碼:


       <!-- {foreach from=$pvnewcomments item=idxcomment} -->
<div style="margin: 8px 0 0 0;"><!-- {if $idxcomment.user_name eq ''} –->匿名用戶<!-- {else} -->{$idxcomment.user_name}<!-- {/if} --><span style="color: #999; font-size: 10px;">({$idxcomment.add_time})</span></div>
<div style="padding: 0 0 8px 0; border-bottom: 1px dotted #ccc;"><a href="goods.php?id={$idxcomment.id_value}">{$idxcomment.content}</a></div>
       <!-- {/foreach} -->

具體調(diào)用條數(shù)、條件等可相應(yīng)修改SQL語句。

好了,趕快把自己的商城也修改一下吧,讓評論也在首頁調(diào)用出來。

 

注:comment_rank = 5 (評論等級)

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章