ecshop首页调用会员留言信息

2012-08-29 23:52 来源:www.chinab4c.com 作者:ecshop专家

      ecshop首页调用会员留言信息,这个问题是值得我们研究的,首先我们调用ecshop的留言在前台首页。首先要想到ecshop会员留言是存储在ecshop数据库表feedback里面的,如果我们要取得会员流言,就必须通过这个表进行数据检索。

   1:在index.php增加以下函数

   function get_index_messg($limit =10){
 
  $sql = "SELECT f.msg_id, f.user_name, f.msg_title, f.msg_type, f.order_id, f.msg_status, f.msg_time, f.msg_area, COUNT(r.msg_id) AS reply " .
            "FROM " . $GLOBALS['ecs']->table('feedback') . " AS f ".
            "LEFT JOIN " . $GLOBALS['ecs']->table('feedback') . " AS r ON r.parent_id=f.msg_id ".
            "WHERE f.parent_id = 0  $where " .
            "GROUP BY f.msg_id ".
            "ORDER by msg_time desc  ".
            "LIMIT 0, $limit";

    $msg_list = $GLOBALS['db']->getAll($sql);
    foreach ($msg_list AS $key => $value)
    {   if($value['order_id'] > 0)
        {
            $msg_list[$key]['order_sn'] = $GLOBALS['db']->getOne("SELECT order_sn FROM " . $GLOBALS['ecs']->table('order_info') ." WHERE order_id= " .$value['order_id']);
        }
        $msg_list[$key]['msg_time'] = local_date($GLOBALS['_CFG']['time_format'], $value['msg_time']);
        $msg_list[$key]['msg_type'] = $GLOBALS['_LANG']['type'][$value['msg_type']];
    }
   
 return $msg_list;


}

   2:ecshop模板index.dwt中增加以下代码

   {foreach from =$get_index_messg item=msg}
        <li><strong>· </strong><a href="message.php">{$msg.msg_title|truncate:40|escape:html}</a></li>
      {/foreach}

    通过以上代码。我们完成了ecshop首页调用会员留言信息。

   来源:http://www.chinab4c.com