找回密码
 注册加入
搜索
查看: 5966|回复: 0

关于推荐跟高亮效果自动消失的问题解释

[分享]
发表于 2011-3-30 14:20:39 | 显示全部楼层 |阅读模式
最近有网友反馈房产信息推荐跟高亮效果过一段时间后自动消失的问题,原因是推荐/高亮有自己的有效期,过了这个有效期后效果就会自动消失。
下面具体分析下是如何实现的:

1.首先是进行推荐/高亮的操作,具体执行代码在source\module\category\house\threadmod.php文件


推荐的部分代码如下:
  1. if($_G['gp_operation'] == 'recommend') {
  2. $isrecommend = intval($_G['gp_isrecommend']);
  3. $statussql = "recommend='".intval($_G['gp_isrecommend'])."'";
  4. $addnumsql = 'todayrecommend=todayrecommend+1';
  5. $expiration = TIMESTAMP + 86400 * 3;
复制代码

其中$expiration = TIMESTAMP + 86400 * 3;就是推荐自己的有效期,如果想要自己修改有效期,更改后面的86400 * 3即可。(86400=3600*24,即1天,这里有效期默认为3天)

高亮的部分代码如下:
  1. elseif($_G['gp_operation'] == 'highlight') {
  2. $highlight_style = $_G['gp_highlight_style'];
  3. $highlight_color = $_G['gp_highlight_color'];
  4. $stylebin = '';
  5. for($i = 1; $i <= 3; $i++) {
  6. $stylebin .= empty($highlight_style[$i]) ? '0' : '1';
  7. }

  8. $highlight_style = bindec($stylebin);
  9. if($highlight_style < 0 || $highlight_style > 7 || $highlight_color < 0 || $highlight_color > 8) {
  10. showmessage('undefined_action', NULL);
  11. }
  12. $statussql = "highlight='$highlight_style$highlight_color'";
  13. $addnumsql = 'todayhighlight=todayhighlight+1';
  14. $expiration = TIMESTAMP + 86400;
复制代码
其中$expiration = TIMESTAMP + 86400;就是高亮自己的有效期,如果想要自己修改有效期,更改后面的86400即可。(86400=3600*24,即1天,这里有效期默认为1天)



2.推荐/高亮的效果是如何取消的,具体执行代码在source\module\category\house\view.php文件
具体代码如下:
  1. if($sortdata['highlight'] || $sortdata['recommend']) {
  2. if($sortdata['highlight']) {
  3. $highlight = DB::fetch_first("SELECT expiration FROM ".DB::table('category_threadmod')." WHERE tid='$tid' AND action='highlight' ORDER BY expiration DESC LIMIT 1");
  4. if(TIMESTAMP > $highlight['expiration'] && !empty($highlight['expiration'])) {
  5. DB::query("UPDATE ".DB::table('category_sortvalue')."$sortid SET highlight='0' WHERE tid='$tid'", 'UNBUFFERED');
  6. }
  7. }

  8. if($sortdata['recommend']) {
  9. $recommend = DB::fetch_first("SELECT expiration FROM ".DB::table('category_threadmod')." WHERE tid='$tid' AND action='recommend' ORDER BY expiration DESC LIMIT 1");
  10. if(TIMESTAMP > $recommend['expiration'] && !empty($recommend['expiration'])) {
  11. DB::query("UPDATE ".DB::table('category_sortvalue')."$sortid SET recommend='0' WHERE tid='$tid'", 'UNBUFFERED');
  12. }
  13. }
  14. }
复制代码
这里如果高亮/推荐的有效期小于当前时间,那么就更新高亮/推荐的操作,即取消效果。

其中的这句代码
  1. DB::query("UPDATE ".DB::table('category_sortvalue')."$sortid SET highlight='0' WHERE tid='$tid'", 'UNBUFFERED');
复制代码
会取消高亮的效果。

其中的这句代码
  1. DB::query("UPDATE ".DB::table('category_sortvalue')."$sortid SET recommend='0' WHERE tid='$tid'", 'UNBUFFERED');
复制代码


会取消推荐的效果。

您需要登录后才可以回帖 登录 | 注册加入

本版积分规则

Archiver|手机版|小黑屋|Discuz!扩展中心 - 杭州富迪文化艺术策划有限公司 版权所有 ( 浙ICP备14042422号-1 )|网站地图QQ机器人

GMT+8, 2025-8-22 00:14 , Processed in 0.340538 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X5.0

© 2001-2025 Discuz! Team.|IP地址位置数据由 纯真CZ88 提供支持

快速回复 返回顶部 返回列表