ECShop v2.7.3打补丁后模版禁止运行php如何在首页调用评论
在index.php最后添加函数:
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 15";
$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;
}
在index.php128行后添加:
$smarty->assign('pvnewcomments', index_get_comments()); // 最新评论
在index.dwt中相应位置调用评论:
<div class="box">
<div class="box_1">
<h3>
<span><a href="/message.php">最新评论</a></span>
</h3>
<div class="boxCenterList RelaArticle">
<!--{foreach from=$pvnewcomments item=idxcomment}-->
<a href="goods.php?id={$idxcomment.id_value}">{$idxcomment.content}</a>
<!--{/foreach}-->
</div>
</div>
</div>
<div class="blank5"></div>
除非注明,均为湛蓝天空原创,转载请注明本文网址:http://skyhome.cn/ecshop/280.html