|
<paypal></paypal> Please leave a tip |
[?] |
Hacking MediaWiki to add a sidebar Google AdSense Search
From Sy
Monetizing MediaWiki > Advertising + Google + AdSense + MediaWiki > Hacking MediaWiki to add a sidebar Google AdSense Search
Contents |
props to [1], and hacked to include accesskey functionality! =)
[edit] Create a file with the code in it
nano /your_wiki/skins/adsense/adsense_search.php
<form action="http://www.google.ca/cse" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="partner-pub-YOUR_CODE_HERE" />
<input type="text" name="q" size="10" <?php echo $skin->tooltipAndAccesskey('search');
if( isset( $this->data['search'] ) ) {
?> value="<?php $this->text('search') ?>"<?php } ?> />
<input type="submit" name="sa" value="Search" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script>
<small>
<span title="How did I do this?" style="border-bottom:1px dotted" id=title>
<a href="http://jrandomhacker.info/Hacking_MediaWiki_to_add_a_sidebar_Google_AdSense_Search">[?]</a>
</span>
</small>
[edit] Edit your skin
[edit] Remove the old search area
Search for p-search and remove or comment-out that block of code.
<div id="p-search" class="portlet">
<h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
<div id="searchBody" class="pBody">
<form action="<?php $this->text('searchaction') ?>" id="searchform"><div>
<input id="searchInput" name="search" type="text"<?php echo $skin->tooltipAndAccesskey('search');
if( isset( $this->data['search'] ) ) {
?> value="<?php $this->text('search') ?>"<?php } ?> />
<input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>" />
<input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>" />
</div></form>
</div>
</div>
[edit] Add in the new search box
<?php require("adsense/adsense_search.php"); ?>
Add it wherever you like. For me, I added it above my Google AdSense block, which is above this final block:
<!-- end of the left (by default at least) column -->
Be warned, your MonoBook.php will be overwritten when you update MediaWiki, so back up this file. Or better yet, re-apply your changes in case they made legit updates to the skin.
[edit] Notes
- Google Adsense Search -- dated

