在discuzNT中加入Adsense广告(只在第一楼显示)

前段时间发布了一篇关于在帖子中adsense插入广告文章http://nt.discuz.net/showtopic-22082.html

但是会在所有的帖子中都插入广告,这样就违反了google中所说最多显示三个广告的规则,我于是少加修改,只在第一层显示广告代码。修改文件/aspx/1/showtopic.aspx  (1为当前模板目录)

templateBuilder.Append(" <!--用户信息结束-->\r\n");
templateBuilder.Append(
" <div class=\"Dright2\">\r\n");
templateBuilder.Append(
"  <div style=\"padding:0px;height:auto!important;height:280px;min-height:280px;\">\r\n");
  
//显示帖子内容
  string adIframe="";//iframe广告
  
//只在第一楼显示广告,否则会违反google规则
  if(post["id"].ToString().Trim()=="1")
  
{
  adIframe
="<div style=\"float:right;\"><iframe src=\"http://www.51aspx.com/ads/bbs_topic_view.htm\" frameborder=\"0\" scrolling=\"no\" height=\"250\" width=\"250\"></iframe></div>";
  }

templateBuilder.Append(
"    <div class=\"article\"><h3>" + post["title"].ToString().Trim() + "</h3><div id=\"message" + post["pid"].ToString().Trim() + "\" class=\"t_msgfont\" style=\"width:99%\">"+ adIframe + post["message"].ToString().Trim() + "</div>\r\n");
templateBuilder.Append(
"    </div>\r\n");


这样既不会违反规则,又达到了广告的效果,怎样?不错吧!

演示效果:http://bbs.51aspx.com/showtopic-434.html

是不是只在第一层显示阿?

posted @ 2007-07-20 11:51  liudao  阅读(720)  评论(1编辑  收藏  举报
51Aspx.com 版权所有