中文站长网 中文站长网 > 程序CMS > 二次开发 > 正文 中文站长资讯

怎样在ECSHOP首页中调用产品最新评论

来源: 网络 【大  时间: 2010年06月30日  字体: [ ] 收藏 我要投稿

首先,在库目录里增加一个文件:Newcomments.lbi 将以下内容加入此文件:

<?php
if(!function_exists(”get_comments”)){
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;
}
}

?>

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

       <!–数据调用-最新评论开始 –>     
    <?php
        $this->assign(’my_comments’,get_comments(5)); // 5代表会条数据
    ?>       
此处是循环输出评论内容:
<!–{foreach from=$my_comments item=comments}–>
      <li><a href=”goods.php?id={$comments.id_value}” target=”_blank”>{$comments.content|truncate:10:”"}</a></li>
      <!–{/foreach}–>

 

然后以上内容只是功能显示,在相应处加入你需要的样式即可。
最后,首页调用此库文件就可以了.

<!– #BeginLibraryItem “/library/Newcomments.lbi” –>  <!– #EndLibraryItem –>

欠扁 支持 很棒 找骂 搞笑 扯淡 不解 吃惊 雷人
>> 更多内容
>> 站长评论
站长常用
本类关注
站长热文
站长推荐
中文站长网致力于为草根站长提供最新,最快,最全的站长资讯,并提供优质的软文推广平台,是中文站长软文推广必上的网站
客服QQ:184491373  客服邮箱:kefu#Zhanne.Com Www.Zhanne.Com 浙ICP备10007729号
关于我们 联系我们 友情链接 广告服务 网站地图 RSS