MediaWiki Code Modifications

From Fishcakes Wiki

Jump to: navigation, search
Edit Menu

Image:Icon_Mediawiki_40px.png MediaWiki Code Modifications

This page contains making MediaWiki Code Modifications to add or remove functionality.

Contents

About MediaWiki Code Modifications

File Uploads

File uploads are disabled by default with MediaWiki. To enable them, first set the upload directory permissions to 777:

/images/            (folder)

Then edit LocalSettings.php and set uploads to true:

$wgEnableUploads = true;

You can add to $wgFileExtensions to allow uploads of any type of file you like. If not included then the $wgFileExtensions line would look something like

$wgFileExtensions = array('png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'mpp', 'pdf');

or

# Add new types to the existing list from DefaultSettings.php
 $wgFileExtensions[] = 'doc';
 $wgFileExtensions[] = 'xls';
 $wgFileExtensions[] = 'pdf';
 $wgFileExtensions[] = 'mpp';


External Images

Displaying external images is disabled by default with MediaWiki. To enable them edit LocalSettings.php:

# Allow external images to be used
$wgAllowExternalImages = true;

To display an image use just insert the image's url:

http://wiki.dansalmon.info/adev/images/imagename.jpg

Example: fishcakes-logo-mediawiki.png

Category Automation

We all like to keep our wikis tidy. This is a little system that shows every user what to copy and paste into their pages to include it in the right category.

  1. Create a new template by visiting http://www.yourdomain.com/wiki/Template:Putincategory
  2. Paste the following into it and save:
[[Image:Icon_Alert_Green_40px.png]] '''Please copy and paste the following into the end
 of your article to include it in this category:'''
 
<nowiki>[[Category:</nowiki>{{PAGENAME}}<nowiki>]]</nowiki>
  1. Upload the alert image Image:Icon_Alert_Green_40px.png to your wiki.
  2. On every category page, simply paste the following:
{{Template:Putincategory}}


Search Engine Friendly URLs

To create SEF or Short URLs do the following:

1. Edit the file LocalSettings.php. Remove or comment out any definitions for $wgArticlePath, then add the following line somewhere near the definition of $wgScriptPath:

# Set Article Path for Search Engine Friendly Short URLs
$wgArticlePath      = "/$1";

2. Edit the file .htaccess. Add the following code:

# Search Engine Friendly Short URLs
RewriteEngine On
RewriteRule ^[^:]*\. - [L]
RewriteRule ^[^:]*\/ - [L]
RewriteRule ^/*$ /index.php?title=Main_Page [L,QSA]
RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]

See also MediaWiki: Short URLs and MediaWiki: Short URLs No Root Access.


Image:Icon Resources 20px.png MediaWiki Resources

Official MediaWiki Resources

Unofficial MediaWiki Resources

Media Wiki Tools


Personal tools