国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

ECShop首頁調用最新評論+(增加顯示評論時間)

2024-04-25 20:42:29
字體:
來源:轉載
供稿:網友

今天給大家介紹一篇文章,是關于ECShop首頁調用最新評論+(增加顯示評論時間),分享給大家供大家參考。具體如下:

在庫目錄里增加一個文件:index_comments.lbi 里面有內容如下:

<?php

if(!function_exists("get_comments")){

function get_comments($num)

{

$sql = 'SELECT * FROM '. $GLOBALS['ecs']->table('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]['add_time'] = $comments[$idx]['add_time'] = local_date

($GLOBALS['_CFG']['time_format'], $row['add_time']);

$comments[$idx]['user_name'] = $row['user_name'];

$comments[$idx]['content'] = $row['content'];

$comments[$idx]['id_value'] = $row['id_value'];

}

return $comments;

}

}

?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<!--數據調用-最新評論開始 -->

<?php

$this->assign('my_comments',get_comments(10)); // 10條數據

?>

<div class="comments">

<!--{foreach from=$my_comments item=comments}-->

<div class="t_l f_l"><a href="goods.php?id={$comments.id_value}" target="_blank">

{$comments.content|truncate:15:""}</a></div><div class="d_r f_r">時間:

{$comments.add_time}</div>

<!--{/foreach}-->

</div>

首頁調用這個庫文件就OK了.

<!-- #BeginLibraryItem "/library/index_comments.lbi" --> <!-- #EndLibraryItem -->

以上就是本文章的內容,希望對大家有所幫助

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 凤庆县| 濮阳市| 长葛市| 宜阳县| 渭源县| 茂名市| 自治县| 闽清县| 溧水县| 敦煌市| 台州市| 邻水| 元阳县| 若羌县| 广灵县| 仲巴县| 色达县| 三亚市| 睢宁县| 仁怀市| 张家口市| 收藏| 大邑县| 农安县| 新竹县| 兴海县| 察哈| 杨浦区| 越西县| 巴马| 灵寿县| 襄汾县| 枣强县| 宁晋县| 永新县| 玉溪市| 陇南市| 乌恰县| 惠安县| 成都市| 上林县|