网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > Blog(博客)/Wiki(维客)/RSS/Cms
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Blog(博客)/Wiki(维客)/RSS/Cms Blog(博客)/、Wiki(维客)、RSS、Cms等WEB 2.0相关技术讨论专区。

Reply
 
Thread Tools Display Modes
  #1   IP: 218.2.66.104
Old 2006-01-27, 11:07 PM
sunshine sunshine is offline
高级会员
 
Join Date: 2006-01-05
Posts: 368
sunshine 正向着好的方向发展
Default Adding Google AdSense to MediaWiki 1.4

If you're interested in running a MediaWiki site with Google AdSense, you should know that in order to comply with the Google TOS, you shouldn't display ads on non-content pages. The following solution will cause ads to not be displayed on Special, User, User talk, Image, Template, and edit/preview pages.

I've solved this by limiting my users' choice of skins to Monobook, and modifying the Monobook.php file as follows:

For a vertical ad below your left-side navigation, after this:

Quote:
echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
?>"><?php $this->msg($special) ?></a></li><?php } ?>
<?php } ?>
</ul>
</div>
</div>
put this:
Quote:
<?php
if(!strstr($_SERVER['REQUEST_URI'], "Special:") &&
!strstr($_SERVER['REQUEST_URI'], "User:") &&
!strstr($_SERVER['REQUEST_URI'], "User_talk:") &&
!strstr($_SERVER['REQUEST_URI'], "Image:") &&
!strstr($_SERVER['REQUEST_URI'], "action=submit") &&
!strstr($_SERVER['REQUEST_URI'], "action=edit") &&
!strstr($_SERVER['REQUEST_URI'], "Template:")) {
include("adsense/adsense_vertical.php");
}
?>
For a horizontal ad at the bottom of your articles, after this:
Quote:
<?php if($this->data['catlinks']) { ?><div id="catlinks"><?php $this->html('catlinks') ?></div><?php } ?>
<!-- end content -->
<div class="visualClear"></div>
put this:

Quote:
<?php
if(!strstr($_SERVER['REQUEST_URI'], "Special:") &&
!strstr($_SERVER['REQUEST_URI'], "User:") &&
!strstr($_SERVER['REQUEST_URI'], "User_talk:") &&
!strstr($_SERVER['REQUEST_URI'], "Image:") &&
!strstr($_SERVER['REQUEST_URI'], "action=submit") &&
!strstr($_SERVER['REQUEST_URI'], "action=edit") &&
!strstr($_SERVER['REQUEST_URI'], "Template:")) {
include("adsense/adsense_horizontal.php");
}
?>
Now, you'll need to create an adsense/ directory in your main wiki directory, and place two files in it, adsense_horizontal.php and adsense_vertical.php as needed.

The contents of my files are as follows:

adsense_vertical.php:

Quote:
<div id="p-advertisement" class="portlet">
<h5>Advertisement</h5>
<div class="pBody">
Paste Google code here
</div>
</div>
adsense_horizontal.php:

Quote:
<div style="border: 1px solid #ccc; padding: 1px; margin-top: 25px;">
Paste Google code here
</div>
Reply With Quote
  #2   IP: 218.2.39.130
Old 2006-01-28, 08:19 AM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

如想在内容的上面加代码:

在<div id="content">下加入:

Quote:
<?php
if(!strstr($_SERVER['REQUEST_URI'], "Special:") &&
!strstr($_SERVER['REQUEST_URI'], "User:") &&
!strstr($_SERVER['REQUEST_URI'], "User_talk:") &&
!strstr($_SERVER['REQUEST_URI'], "Image:") &&
!strstr($_SERVER['REQUEST_URI'], "action=submit") &&
!strstr($_SERVER['REQUEST_URI'], "action=edit") &&
!strstr($_SERVER['REQUEST_URI'], "Template:")) {
include("adsense/adsense_horizontal.php");
}
?>
Reply With Quote
  #3   IP: 218.2.67.203
Old 2006-01-28, 10:34 AM
lingerie lingerie is offline
初级会员
 
Join Date: 2006-01-14
Posts: 10
lingerie 正向着好的方向发展
Default

如想在内容的上面加代码:

在<a name="top" id="top"></a>下加入:
Quote:
<?php
if(!strstr($_SERVER['REQUEST_URI'], "Special:") &&
!strstr($_SERVER['REQUEST_URI'], "User:") &&
!strstr($_SERVER['REQUEST_URI'], "User_talk:") &&
!strstr($_SERVER['REQUEST_URI'], "Image:") &&
!strstr($_SERVER['REQUEST_URI'], "action=submit") &&
!strstr($_SERVER['REQUEST_URI'], "action=edit") &&
!strstr($_SERVER['REQUEST_URI'], "Template:")) {
include("adsense/adsense_horizontal.php");
}
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:08 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.