但是会在所有的帖子中都插入广告,这样就违反了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 " );
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 " );
这样既不会违反规则,又达到了广告的效果,怎样?不错吧!
本文转自 liudao 博客园博客,原文链接:http://www.cnblogs.com/liudao/archive/2007/07/20/825273.html,如需转载请自行联系原作者