定型管 電子鈑金
返回列表 回復 發帖

帖子標題:[分享] Ecshop如何設置實時刷新瀏覽次數

1、  修改article.dwt
瀏覽次數: {insert name='click_count' article_id=$id} 次
上面代碼的意思是調用lib_insert.php裏的 insert_click_count()方法,並且把id作為參數傳進去
2、在lib_insert.php裏面添加上面的function
function insert_click_count($arr){
$need_cache = $GLOBALS['smarty']->caching;
  $need_compile = $GLOBALS['smarty']->force_compile;
$GLOBALS['smarty']->caching = false;
  $GLOBALS['smarty']->force_compile = true;
  $click_count=get_article_click_count($arr['article_id']);
  $GLOBALS['smarty']->caching = $need_cache;
$GLOBALS['smarty']->force_compile = $need_compile;
return $click_count;
}
3、在lib_article.php裏面添加上面用到的查詢數據庫的方法
function get_article_click_count($article_id){
global $db, $ecs;
  $sql = "SELECT CLICK_COUNT FROM ".$ecs->table('article').'  where article_id='.$article_id;
  $click_count= $db->getOne($sql);
  return $click_count;
  }
這樣就OK了。


ecshop模板
网站模板
提醒您: 您在"ECSHOP 交流討論區"交流請遵守台灣法律規範,"最模板" 發表的文章《Ecshop如何設置實時刷新瀏覽次數》版權歸屬作者所有,如是轉貼版權歸屬原作者所有.本論壇不對其真實性做任何考證.
返回列表