Mike Brawley Exploring the World!

22Nov/110

How to add a banner/image to the MediaWiki sidebar

To add a banner to the MediaWiki sidebar follow the next steps:

1. Find the file MonoBook.php in skins/MonoBook.php path (if you're using monobook)
2. Download the file.
3. Go to line 185 or file the line:

 </div><!-- end of the left (by default at least) column -->

4. Add the next lines of code before the line you find above:

	<!-- begin of banner1 -->
	<div class='generated-sidebar portlet'>
	<h5><?php $this->msg('sidebar-banner1-headingtext') ?></h5>
	<div style="border: 1px solid #B0B0B0; background-color: #FFFFFF;">
	<a href="<?php $this->msg('sidebar-banner1-url') ?>">
	<img width="100%" title="<?php $this->msg('sidebar-banner1-alttext') ?>"
		alt="<?php $this->msg('sidebar-banner1-alttext') ?>"
		src="<?php $this->msg('sidebar-banner1-imgsrc') ?>" /></a>
	</div></div>
	<!-- end of banner1 -->

Should look as follows

?>
    <!-- begin of banner1 -->
    <div class='generated-sidebar portlet'>
    <h5><?php $this->msg('sidebar-banner1-headingtext') ?></h5>
    <div style="border: 1px solid #B0B0B0; background-color: #FFFFFF;">
    <a href="<?php $this->msg('sidebar-banner1-url') ?>">
    <img width="100%" title="<?php $this->msg('sidebar-banner1-alttext') ?>"
        alt="<?php $this->msg('sidebar-banner1-alttext') ?>"
        src="<?php $this->msg('sidebar-banner1-imgsrc') ?>" /></a>
    </div></div>
    <!-- end of banner1 -->
    </div><!-- end of the left (by default at least) column -->

5.Create new articles / page named MediaWiki:sidebar-banner1-headingtext and write the banner heading. Example: Sponsor
6. Create new articles / page named MediaWiki:sidebar-banner1-url and write the The destination URL of this banner. Example: http://www.website.com/abc.html
7. Create new articles / page named MediaWiki:sidebar-banner1-alttext and write the alt="" parameter of an HTML <img> tag. Example: Best dog training
8. Create new articles / page named MediaWiki:sidebar-banner1-imgsrc and write the src="" parameter of an HTML <img> tag. The URL of the banner image. It may be the address of an image uploaded to your Wiki {{filepath:banner123.png}}, or the address of an external image. Example: http://www.website.com/banner123.gif

Do note that if you upgrade MediaWiki to the latest version it will overwrite the MonoBook.php file and you will have to re-edit the file for this to work.