|
功能效果叙述如下: (1)、如果指定了tid的话 这个广告只在这个帖子下显示; (2)、如果没有指定tid的话 这个广告可以在任何一个帖子下显示; (3)、综合以上,某个帖子的tid被指定了以后,这个帖子下方可显示指定tid和未指定tid的广告 这个是随机显示的
1、打开template/admin/setadvert.htm文件, 找到: - <tr class="tr1 vt">
- <td class="td1">选择广告位</td>
- <td class="td2">
- <select id="advert_ckey" name="advert[ckey]" class="select_wa" onchange="showSelCate(this.options[this.selectedIndex].value)">
- <option value="" disabled>请选择要投放的广告位</option>
- <option value="" disabled></option>
- $optCates
- </select>
- <span class="gray" id="cateDescrip"></span>
- </td>
- <td class="td2"><div class="help_a"></div> </td>
- </tr>
上上上方添加如下代码: - <!--汉网广告位定制start by rickyleo-->
- <tr class="tr1 vt">
- <td class="td1">绑定帖子tid</td>
- <td class="td2">
- <input type="text" name="advert[tid]" value="$advert[tid]">
- <span class="help_a">绑定某个特定的帖子后,该广告只针对这个帖子有效,'0'表示任意帖子</span>
- </td>
- <td class="td2"><div class="help_a"></div> </td>
- </tr>
- <!--广告位定制end-->
2、打开admin/setadvert.php文件 找到: - $advert['etime'] = PwStrtoTime($advert['etime']) + 86399;
下下下方添加如下代码: - //汉网广告位定制start by rickyleo
- $advert['tid'] = (int)$advert['tid'];
找到以下所有的(共3处): - 'descrip' => $advert['descrip'],
下下下方添加如下代码: - 'tid' => $advert['tid'],//rickyleo
3、打开require/common.php文件 找到: - function pwAdvert($advKey, $fid = 0, $lou = -1, $scr = 0) {
- ……
- }
整个函数替换成: - function pwAdvert($advKey, $fid = 0, $lou = -1, $scr = 0) {
- global $timestamp, $db_advertdb, $db_mode, $_time;
- if (empty($db_advertdb[$advKey])) return false;
- $hours = $_time['hours'] + 1;
- $tid = $GLOBALS['tid']; //广告绑定帖子tid by rickyleo
- $fid || $fid = $GLOBALS['fid'];
- $scr || $scr = $GLOBALS['SCR'];
- $scr = strtolower($scr);
- $lou = (int) $lou;
- $tmpAdvert = $db_advertdb[$advKey];
- if ($db_advertdb['config'][$advKey] == 'rand') {
- shuffle($tmpAdvert);
- }
- $arrAdvert = array();
- $advert = '';
- foreach ($tmpAdvert as $key => $value) {
- 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)) {
- continue;
- }
- if ((!$value['ddate'] && !$value['dweek']) || ($value['ddate'] && strpos(",{$value['ddate']},", ",{$_time['day']},") !== false) || ($value['dweek'] && strpos(",{$value['dweek']},", ",{$_time['week']},") !== false)) {
- $arrAdvert[] = $value['code'];
- $advert .= is_array($value['code']) ? $value['code']['code'] : $value['code'];
- if ($db_advertdb['config'][$advKey] != 'all') break;
- }
- }
- return array($advert, $arrAdvert);
- }
4、打开admin/cache.php文件 找到: - $ad['etime'] = $rt['etime'];
下下下方添加如下代码: - $ad['tid'] = $rt['tid'];//广告绑定帖子tid by rickyleo
|