
- 帖子
- 3
- 积分
- 106
- 体力
- 103 点
- 金币
- 1
- 威望
- 0
- 来自
- 台灣
|

本帖最后由 eh99 于 2014-6-13 16:20 编辑
1.首先 在../httpdocs/themes/lativ/library
新增 index_comments.lbi 這個庫項目,
代碼如下- <?php
- if(!function_exists("get_comments")){
- function get_comments($num)
- {
- $sql = 'SELECT a.*,b.goods_id,b.goods_thumb,b.goods_name FROM '. $GLOBALS['ecs']->table('comment') .
- ' AS a,'. $GLOBALS['ecs']->table('goods') .'AS b WHERE a.status = 1 AND a.parent_id =0 and a.comment_type=0 and a.id_value=b.goods_id '.
- ' ORDER BY a.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'];
- $comments[$idx]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);/*呼叫被評論的產品縮圖*/
- $comments[$idx]['goods_name'] = $row['goods_name'];/*呼叫被評論的產品名稱*/
- }
- return $comments;
- }
- }
- ?>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <!--?? -->
- <?php
- $this->assign('my_comments',get_comments(10)); // /*呼叫評論數目*/
- ?>
- <marquee scrollamount="2.5" direction="right"> /*scrollamount=評論軸滑動速度;direction=產品縮圖跑的方向*/
- <!--{foreach from=$my_comments item=comments}-->
- <td width="65" height="50" align="left"><a href="goods.php?id={$comments.id_value}" target="_blank"><img src="{$comments.goods_thumb}" border="1" width="60" height="60" style=" border:1px #CCCCCC solid;"/></a></td>
- <td width="130" align="left">
- <div style="height:3px; overflow:hidden;"> </div>
- <div>{$comments.user_name|truncate:100:""}</div>
- <div><a href="goods.php?id={$comments.id_value}" target="_blank"><font style=" color:#FF0000; font-size:14px;">{$comments.goods_name}</font></a></div>
- <div>{$comments.content|truncate:100:""}</div>
- <div style="color:#999999;">{$comments.add_time}</div>
- </td>
- </tr>
- <!--{/foreach}-->
- </marquee>
复制代码
2.到 /httpdocs/themes/lativ 下,
找到 index.dwt 檔案修改
在第333行加入 下面程式碼呼叫 index_comments.lbi
- <div style="margin-bottom:20px" id="focus">
- <!-- #BeginLibraryItem "/library/index_comments.lbi" --><!-- #EndLibraryItem -->
- </div>
复制代码
3.成功啦!www.eh99.com.tw 歡迎有問題可以問我喔!
不過我這次針對框架中間的方法,由於俺還是新手其他例如右側左側上方的方法還沒研究出來;
希望有高手指導囉!
|
|