Mike Brawley Exploring the World!

30Apr/120

How to change the text of the talk tab in MediaWiki

The tabs at the top of MediaWiki are an important part of the user interface. Some of the names might not be appropriate for your wiki though.  For instance I run a hiking wiki for washington state called TrailWIKI.org.  I have changed the talk page tab from discussion to trip reports as I use this page for people to leave a trip report about that trail.

Making this change is easy, navigate to the page called MediaWiki:Talk.  This page may not exist yet on your wiki and is pulling the default value.  When editing this page enter the text you wish to display on the talk tab.  You can also use magic words to pull information dynamically and display it on the tab.

Tagged as: No Comments
11Jan/120

How to patch MediaWiki to the latest release

You can only patch MediaWiki inbetween sub versions.  You cannot patch between main releases.   Download the latest patch from www.mediawiki.org.   In this example I am going to patch from 1.17.1 to 1.17.2.

Download page.

http://lists.wikimedia.org/pipermail/mediawiki-announce/2012-January/000106.html

The file you need to download is the one under.
Patch to previous version (1.17.1), without interface text: http://download.wikimedia.org/mediawiki/1.17/mediawiki-1.17.2.patch.gz
Copy the file to the root of the wiki directory on your server.  This is usually not the actual root, its usually /w

Unzip patch & store it in wiki web dir.

gunzip mediawiki-1.17.2.patch.gz

You can also unzip the mediawiki-1.17.2.patch.gz file on your local computer using 7-Zip and then copy the  mediawiki-1.17.2.patch file to the MediaWiki directory on your website.

Apply the patch

cd /var/www/html/
patch -i mediawiki-1.17.2.patch -p 1

Remove patch file.

rm -rf mediawiki-1.17.2.patch 

After patching run the update.php script in the MediaWiki Maintenance directory

verify version

http://webserver/wiki/index.php/Special:Version

Tagged as: No Comments
23Nov/111

How to remove toolbox from the sidebar in MediaWiki

To remove the toolbox from MediaWiki sidebar

  1. Open MediaWiki:Common.css
  2. Edit MediaWiki:Common.css and add the following lines of code to the bottom
    /* remove Toolbox */
    #p-tb { display:none !important; }
  3. Save your changes and then clear your browsers cache. I you do not know how to clear your browsers cache check out http://www.wikihow.com/Clear-Your-Browser%27s-Cache

Tagged as: 1 Comment
23Nov/110

Create a MediaWiki Skin from MonoBook

Create MediaWiki Skin

You can create a skin all by yourself by following the steps provided below:
Go to the /skins folder within your Mediawiki directory;
Copy the /monobook directory and rename it with the name of your skin, for example:

mywikiskin

Copy the MonoBook.php file and rename it with the name of your skin, for example:

MyWikiSkin.php

Edit MyWikiSkin.php and change the class name to SkinMyWikiSkin, for example:

class SkinMyWikiSkin extends SkinTemplate;

In MyWikiSkin.php, change make the other class to have your skin name together with the word Template, for example:

class MyWikiSkinTemplate extends QuickTemplate;

In MyWikiSkin.php, make $this->skinname to have a string value of your skin name, for example:

'mywikiskin';

In MyWikiSkin.php, make $this->template to have a string value of your skin name properly capitalised with the word Template, for example:

'MyWikiSkinTemplate';

In MyWikiSkin.php find the following lines and replace monobook with mywikiskin in the path settings for the CSS files:

$out->addStyle( 'mywikiskin/main.css', 'screen' );
$out->addStyle( 'mywikiskin/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
$out->addStyle( 'mywikiskin/IE55Fixes.css', 'screen', 'IE 5.5000' );
$out->addStyle( 'mywikiskin/IE60Fixes.css', 'screen', 'IE 6' );
$out->addStyle( 'mywikiskin/IE70Fixes.css', 'screen', 'IE 7' );
$out->addStyle( 'mywikiskin/rtl.css', 'screen', '', 'rtl' );

In your /mywikiskin directory edit the image and CSS files;
Edit and customise MyWikiSkin.php as you please;
In LocalSettings.php set

$wgDefaultSkin = 'mywikiskin'

You can now enjoy the new skin you have prepared!

Tagged as: No Comments
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.

Tagged as: No Comments
11Nov/110

Remove the Advanced Search Box in MediaWiki

I have a wiki for hiking in Washington State called TrailWIKI.org  I use a couple different namespaces for internal use and do not want users to be confused on the search page with all the additional namespaces.  I could not find a way to remove only some of the namespaces from the advanced search box so I decided to remove the entire advanced search box.

To prevent this what I did was remove the Advanced Search box from the search page.  I also added aditional namespaces to my default namespaces to search so uses can search namespaceslike talk, user, and categories, help...

First you will need to add additional namespaces to the search default.

LocalSettings.php add the following in the end:

# SEARCH: default namespaces to search in
$myAdditionalNamespacesSearchDefault = array(
NS_MAIN,
NS_TALK,
NS_USER,
NS_USER_TALK,
NS_HELP,
NS_HELP_TALK,
NS_CATEGORY,
NS_CATEGORY_TALK
);

edit the namespaces above with the namspaces you want to search in.

Now we need to remove the advance search box from the search page.

Then open includes/specials/SpecialSearch.php
and change the following code arround line 268

$wgOut->addHTML( $this->powerSearchBox( $term ) );
wfProfileOut( $fname );
}

to this

// the following line was commented to hide the advanced search box
		// $wgOut->addHTML( $this->powerSearchBox( $term ) );
		wfProfileOut( $fname );
	}

Then you may need to change the message that appears when no results are found, to do this go to Special:AllMessages and change the "nonefound" message as required.

The original message is
'''Note''': Only some namespaces are searched by default. Try prefixing your query with ''all:'' to search all content (including talk pages, templates, etc), or use the desired namespace as prefix.

You may change it to something like
'''Suggestions''':
* Make sure all words are spelled correctly.
* Try different keywords.
* Try more general keywords.
* Try fewer keywords.
See my example at http://www.trailwiki.us/wiki/Special:Search?search=asdf&go=Go
By the way, you can enhance the searching by allowing search suggestion:
add the following like to LocalSettings.php

# turn on search suggestion
$wgEnableMWSuggest = true;

My new search screen shows as following

No pages found

Pages Found

Hope this helps you out! Smile

Tagged as: No Comments
Rand Paul - Restore America