php专区

 首页 > php专区 > PHP应用 > CMS建站 > ecshop实时刷新浏览次数 - ecshop

ecshop实时刷新浏览次数 - ecshop

分享到:
【字体:
导读:
          ecshop是有缓存机制的,所以本来文章的浏览次数不是实时刷新的,如果把缓存去掉肯定是得不偿失的,所以要用到局部刷新的方法,下面就由ECSHOP开发中心的技术,教大家如何用lib_insert php,来实...

ecshop实时刷新浏览次数

ecshop是有缓存机制的,所以本来文章的浏览次数不是实时刷新的,如果把缓存去掉肯定是得不偿失的,所以要用到局部刷新的方法,下面就由ECSHOP开发中心的技术,教大家如何用lib_insert.php,来实现局部刷新.

1、修改article.dwt

1  浏览次数:{insert name='click_count' article_id=$id} 次

上面代码的意思是调用lib_insert.php里的 insert_click_count()方法,并且把id作为参数传进去.

2、在lib_insert.php里面添加上面的function:

  1. function insert_click_count($arr){ 
  2.  $need_cache = $GLOBALS['smarty']->caching; 
  3.   $need_compile = $GLOBALS['smarty']->force_compile; 
  4.  
  5.   $GLOBALS['smarty']->caching = false; 
  6.   $GLOBALS['smarty']->force_compile = true; 
  7.  
  8.   $click_count=get_article_click_count($arr['article_id']); 
  9.  
  10. $GLOBALS['smarty']->caching = $need_cache
  11.  $GLOBALS['smarty']->force_compile = $need_compile
  12.  
  13.   return $click_count
  14.  } 

3、在lib_article.php里面添加上面用到的查询数据库的方法

  1. function get_article_click_count($article_id){ 
  2. global $db$ecs
  3.  $sql = "SELECT CLICK_COUNT FROM ".$ecs->table('article').'  where article_id='.$article_id
  4.  $click_count$db->getOne($sql); 
  5.  return $click_count
  6.  } 
分享到:
ecshop网站ecs_stats表总是占用太大系统...
ecshop网站ecs_stats表总是占用太大系统崩溃 用ecshop建网站,当达到一定是时间,有蜘蛛等访问时候,数据库老是经常爆满,数据表ecs_stats总是很大,要定期清除. 除了ecs_stats还有哪些可以定期清除呢?如何清除? 这个因为ECSHOP默认是记录访问统计信息,像国内一些搜索引擎他是一天访问估计有...
ecshop运行超过30秒超时的限制解决办法 -...
ecshop运行超过30秒超时的限制解决办法 ecshop运行超过服务器默认的设置30秒的限制时会出现类似的报错 Fatal error: Maximum execution time of 30 seconds exceeded in\includes\lib_insert.php on line 16 一、修改php.ini 找到max_execution_time = 30 ; 修改成max_execution_time = ...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……