论坛风格切换
  • 3509阅读
  • 0回复

[定制开发功能]论坛广告体系阅读页增加帖子tid绑定方案 [复制链接]

上一主题 下一主题
离线rickyleo
 

发帖
315
金币
0
威望
99
只看楼主 倒序阅读 使用道具 楼主  发表于: 2011-10-28
功能效果叙述如下:
(1)、如果指定了tid的话 这个广告只在这个帖子下显示;
(2)、如果没有指定tid的话 这个广告可以在任何一个帖子下显示;
(3)、综合以上,某个帖子的tid被指定了以后,这个帖子下方可显示指定tid和未指定tid的广告 这个是随机显示的

1、打开template/admin/setadvert.htm文件,
找到:
  1. <tr class="tr1 vt">
  2.         <td class="td1">选择广告位</td>
  3.         <td class="td2">
  4.             <select id="advert_ckey" name="advert[ckey]" class="select_wa" onchange="showSelCate(this.options[this.selectedIndex].value)">
  5.                 <option value="" disabled>请选择要投放的广告位</option>
  6.                 <option value="" disabled></option>
  7.                 $optCates
  8.             </select>
  9.             <span class="gray" id="cateDescrip"></span>
  10.         </td>
  11.         <td class="td2"><div class="help_a"></div> </td>
  12.     </tr>

上上上方添加如下代码:    
  1. <!--汉网广告位定制start by rickyleo-->
  2.         <tr class="tr1 vt">
  3.             <td class="td1">绑定帖子tid</td>
  4.             <td class="td2">            
  5.                 <input type="text" name="advert[tid]" value="$advert[tid]">
  6.                 <span class="help_a">绑定某个特定的帖子后,该广告只针对这个帖子有效,'0'表示任意帖子</span>
  7.             </td>
  8.             <td class="td2"><div class="help_a"></div> </td>
  9.         </tr>
  10.     <!--广告位定制end-->

2、打开admin/setadvert.php文件
找到:
  1. $advert['etime'] = PwStrtoTime($advert['etime']) + 86399;

下下下方添加如下代码:    
  1. //汉网广告位定制start by rickyleo
  2.     $advert['tid'] = (int)$advert['tid'];

找到以下所有的(共3处):    
  1. 'descrip'    => $advert['descrip'],

下下下方添加如下代码:    
  1. 'tid'        => $advert['tid'],//rickyleo

3、打开require/common.php文件
找到:
  1. function pwAdvert($advKey, $fid = 0, $lou = -1, $scr = 0) {
  2.         ……
  3.     }

整个函数替换成:  
  1. function pwAdvert($advKey, $fid = 0, $lou = -1, $scr = 0) {
  2.         global $timestamp, $db_advertdb, $db_mode, $_time;
  3.         if (empty($db_advertdb[$advKey])) return false;
  4.         $hours = $_time['hours'] + 1;
  5.         $tid = $GLOBALS['tid']; //广告绑定帖子tid by rickyleo
  6.         $fid || $fid = $GLOBALS['fid'];
  7.         $scr || $scr = $GLOBALS['SCR'];
  8.         $scr = strtolower($scr);
  9.         $lou = (int) $lou;
  10.         $tmpAdvert = $db_advertdb[$advKey];
  11.         if ($db_advertdb['config'][$advKey] == 'rand') {
  12.             shuffle($tmpAdvert);
  13.         }
  14.         $arrAdvert = array();
  15.         $advert = '';
  16.         foreach ($tmpAdvert as $key => $value) {
  17.             if ($value['stime'] > $timestamp || $value['etime'] < $timestamp || ($value['dtime'] && strpos(",{$value['dtime']},", ",{$hours},") === false) || ($value['mode'] && strpos($value['mode'], $db_mode) === false) || ($value['page'] && (strpos($value['page'], ",$scr,") === false || ($scr == 'read' && $value['page'] == 'thread'))) || ($value['fid'] && $scr != 'index' && strpos(",{$value['fid']},", ",$fid,") === false) || ($value['lou'] && strpos(",{$value['lou']},", ",$lou,") === false) || ($scr == 'read' && $value['tid'] && $tid && $value['tid'] != $tid)) {
  18.                 continue;
  19.             }
  20.             if ((!$value['ddate'] && !$value['dweek']) || ($value['ddate'] && strpos(",{$value['ddate']},", ",{$_time['day']},") !== false) || ($value['dweek'] && strpos(",{$value['dweek']},", ",{$_time['week']},") !== false)) {
  21.                 $arrAdvert[] = $value['code'];
  22.                 $advert .= is_array($value['code']) ? $value['code']['code'] : $value['code'];
  23.                 if ($db_advertdb['config'][$advKey] != 'all') break;
  24.             }
  25.         }
  26.         return array($advert, $arrAdvert);
  27.     }

4、打开admin/cache.php文件
找到:
  1. $ad['etime'] = $rt['etime'];

下下下方添加如下代码:
  1. $ad['tid']     = $rt['tid'];//广告绑定帖子tid by rickyleo
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
提到某人:
选择好友
上一个 下一个