<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_51747"> PHPCMS 根据栏目放置 加载不同的广告<br>首先要创建一个广告的配置文件,放置在caches/config/ad.php: <div class="blockcode"> <div id="code_ZiM"><ol> <li>//加载广告</li> <li> <li>function ad_block($catid){</li> <li> <li> $adblocks = pc_base::load_config('ad',$catid);</li> <li> <li> if(empty($adblocks)){</li> <li> <li> $model = pc_base::load_model("category_model");</li> <li> <li> $catid = $model->get_one(array('catid'=>$catid));</li> <li> <li> $adblocks = pc_base::load_config('ad',$catid['parentid']);</li> <li> <li> </li> <li> <li> if(empty($adblocks) && $catid['parentid'] != 0){</li> <li> <li> $adblocks = ad_block($catid['parentid']);</li> <li> <li> }</li> <li> <li> </li> <li> <li> if(empty($adblocks)||is_array($adblocks)){</li> <li> <li> $adblocks = pc_base::load_config('ad','other');</li> <li> <li> }</li> <li> <li> }</li> <li> <li> return $adblocks;</li> <li> <li>}</li> </ol></div> <em onclick="copycode($('code_ZiM'));">复制代码</em> </div> <div class="blockcode"> <div id="code_rD7"><ol> <li>$ad = array();</li> <li> <li>$ad[1234]=<<<EOF<li><li><!-- 广告位:1234-栏目独立广告位 --></li> <li> <li><script type="text/javascript" >BAIDU_CLB_SLOT_ID = "XXXXX";</script></li> <li> <li><script type="text/javascript" src="http://cbjs.baidu.com/js/o.js"></script></li> <li> <li>EOF;</li> <li> <li> <li>$ad['other']=<<<EOF<li><li><!-- 广告位:0000-默认显示广告位 --></li> <li> <li><script type="text/javascript" >BAIDU_CLB_SLOT_ID = "XXXXX";</script></li> <li> <li><script type="text/javascript" src="http://cbjs.baidu.com/js/o.js"></script></li> <li> <li>EOF;</li> <li> <li> <li>return $ad;</li> </ol></div> <em onclick="copycode($('code_rD7'));">复制代码</em> </div> </td></tr></table> <div id="comment_51747" class="cm"> </div> <div id="post_rate_div_51747"></div> <br><br>