Support jOOmla! Autoit!
文章右侧增加广告的补充与扩展 输出PDF 打印 E-mail
Author Author: Autoit | Date Date:2007-08-09 | View Count View: 11504 | Digg Count Digg: 32

开始是这样:[参考:http://www.autoit.cn/index.php/content/view/48/25/]

<!--贴内右侧广告开始 by www.autoit.cn-->
<div style='float:right;'>
<div align='center'>
<!--这里放你的广告代码或者建立一个模块位置,在后台用我的 mod_htmlcode 模块放在这个位置...放你想放的一切!-->
</div>
</div>    
<!--贴内右侧广告结束 by www.autoit.cn-->

如果首页有文章显示的话,而首页[及blog形式页]不想显示这些AD可以前后增加一句变为:

 

<?php if  ($option !="com_frontpage" && !$params->get( 'intro_only' ) && $task != "blogsection") { ?>
<!--贴内右侧广告开始 by www.autoit.cn-->
<div style='float:right;'>
<div align='center'>
<!--这里放你的广告代码或者建立一个模块位置,在后台用我的 mod_htmlcode 模块放在这个位置...放你想放的一切!-->
</div>
</div>    
<!--贴内右侧广告结束 by www.autoit.cn-->
<?php } ?>

当然很多人都需要个随机性的,如果你用 google ad 的话,他默认是随机出现, 在 Google 推荐AD2.0 出现之前, 如果文章里放一推荐 firfox 的话,一直出现总不是很好,这个时候就想 随机的出现 Firefox 及 Adsense 等。[比如 dvbox.cn 的左上角的 推荐], 当然现在 Google 推荐AD2.0 的出现已经弥补了这个问题。 不过,如果更多的人还是要随机的出现多个不同的图片或广告类的。那么 实现方法也是很容易: 定义个数组, 随机输出就可以了。

大概形式为:

<?php 
$autoit = array('a','b','c')
echo $autoit[rand(0,3)];
?>

具体实例例如:

<?php 
$autoit = array('<iframe scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="320" height="80" src="http://u.sl.iciba.com/union/pw/style_587.html?uid=28743&sid=0&adid=587&adtype=11" id="ksu_style_587"></iframe>','<iframe scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="80" height="250" src="http://u.sl.iciba.com/union/pw/style_679.html?uid=28743&sid=0&adid=679&adtype=11" id="ksu_style_679"></iframe>','<iframe scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="320" height="120" src="http://union.wps.kingsoft.com/union/wpsau/style_740.html?uid=28743&sid=0" id="ksu_style_740"></iframe>','<iframe scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="100" height="300" src="http://u.www.duba.net/union/scan/style_407.html?uid=28743&sid=0&adid=407&adtype=42" id="ksu_style_407"></iframe>','<iframe scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="150" height="25" src="http://union.shop.kingsoft.com/union/shop/style_121.html?uid=28743&sid=0&adid=121&adtype=7" id="ksu_style_121"></iframe>'); 
echo $autoit[rand(0,4)];
?>

将这段直接替换上面的:

<!--这里放你的广告代码或者建立一个模块位置,在后台用我的 mod_htmlcode 模块放在这个位置...放你想放的一切!-->

就可以实现了打开文章后,右侧可以随机出现... Demo可参考: http://huihuiart.gnway.net

在比如:

<?php 
$autoit = array('img_1','img_2','img_3')
echo '<img src="images/'. $autoit[rand(0,3)] .'.jpg';
?>

就是随机的输出 images 目录下的 img_1.jpg , img_2.jpg, img_3.jpg 3个图片。 如果要5个图的话,

<?php 
$autoit = array('img_1','img_2','img_3','img_4','img_5')
echo '<img src="images/'. $autoit[rand(0,4)] .'.jpg';
?>

也可以这样:

<?php 
$autoit = array('img_1.jpg','img_2.jpg','img_3.jpg','img_4.jpg','img_5.jpg')
echo '<img src="images/'. $autoit[rand(0,4)];
?>

灵活用去了...


Permanent URL: http://www.autoit.cn/index.php/content/view/109/25.html

Shares: Google书签 Yahoo书签 雅虎收藏夹 365Key网摘 新浪ViVi 百度收藏 天极网摘 diglog 和讯网摘 POCO网摘 YouNote网摘 博拉网 天下图摘 spurl blogmarks BlinkList reddit digg Del.icio.us   |  Tags: 广告  随机  

 
joomla comment 3.12 首页 发表评论Itemid值问题   文章内增加网摘按钮