ECSHOP二次开发之首页调用商品评论

1.首先在library创建index_comments.lib文件,2.然后index.php写一个方法:function get_comments($num){ $sql = 'SELECT * FROM ecs_comment '. ' WHERE status = 1 AND parent_id = 0 and comment_type=0 '. ' ORDER BY add_time DESC'; if ($num > 0) { $sql .= ' LIMIT ' . $num; } //echo $sql; $res = $GLOBALS['db']->getAll($sql); $comments = array(); foreach ($res AS $idx => $row) { $comments[$idx]['user_name'] = $row['user_name']; $comments[$idx]['content'] = $row['content']; $comments[$idx]['id_value'] = $row['id_value']; } return $comments;}3.在index.php大概128行处添加$smarty->assign('my_comments',get_comments(10)); // 用户评论4.index_comments添加, <!–{foreach from=$my_comments item=comments}–> <a href="goods.php?id={$comments.id_value}" target="_blank" style="float:left;">{$comments.content|truncate:30:""}</a> <font style="margin-left:20px; color:#CCC; float:right;">{$comments.add_time}</font><br> <!–{/foreach}–>5.在首页index.dwt调用商品用户评论<!– #BeginLibraryItem "/library/index_comments.lbi" –><!– #EndLibraryItem –> 当花儿枯萎的时候,就是它生命终结的时候,

ECSHOP二次开发之首页调用商品评论

相关文章:

你感兴趣的文章:

标签云: