MediaWiki Code Modifications
From Fishcakes Wiki
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';
- See MediaWiki Manual:Configuring File Uploads.
- See MediaWiki: Uploading non image files
- See MediaWiki: Mime type detection.
- Note: If you decide to allow any kind of file, make sure your mime detection is working and think about enabling virus scans for uploads.
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:
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.
- Create a new template by visiting http://www.yourdomain.com/wiki/Template:Putincategory
- 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>
{{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.
MediaWiki Resources
Official MediaWiki Resources
- mediawiki.org — official MediaWiki website.
- mediawiki.org Manual — contents page.
- mediawiki.org Help — contents page.
- mediawiki.org Help: FAQ — good place for quick answers.
- meta.wikimedia.org Help — User Guide
- wikimedia.org Mailing List — sign up for email updates.
Unofficial MediaWiki Resources
- askdrwiki.com Ask Dr Wiki — helpful advice about all things wiki.
- lifehacker.com How to Guide — excellent first start guide with Video Tutorial by Gina Trapani.
- mikeswikidev Mediawiki Dev Blog — by Mike Baynton.
- mwusers.com Media Wiki Users — forum and mailing lists for users and administrators.
- wikibooks.org Administrators Handbook — excellent admin guide.
- wikibooks.org How to Start a Wiki — excellent guide including a list of free and paid Wiki hosts.
- wikieducator.org Wiki Educator — community site with guides for education projects linked with the development of free content.
Media Wiki Tools
- HTML to Wiki Converter for HTML Tables — excellent tool which converts HTML table tags into their wiki equivalents.

