MediaWiki - Local settings

From XennisWiki
Jump to: navigation, search

All following changes refer, unless otherwise specified, to the file LocalSettings.php, which is located in the root directory of your wiki. Detailed information you can find at Manual:LocalSettings.php

Set user / group permissions

Further information: Manual:$wgGroupPermissions

To change the rights of non registered users (*), add the following lines to the LocalSettings.php file. Set the respective values to true or false. For instance these sittings allows only reading:

## Set group permissions
$wgGroupPermissions['*'    ]['createaccount']   = false;
$wgGroupPermissions['*'    ]['read']            = true;
$wgGroupPermissions['*'    ]['edit']            = false;
$wgGroupPermissions['*'    ]['createpage']      = false;
$wgGroupPermissions['*'    ]['createtalk']      = false;

Use custom namespaces

Further information: custom namespaces

To create for instance the namespaces Portal and Documentation (both with an talk namespace):

## Custom namespaces
$wgExtraNamespaces[100] = "Portal";
$wgExtraNamespaces[101] = "Portal_talk";
$wgExtraNamespaces[500] = "Documentation";
$wgExtraNamespaces[501] = "Documentation_talk";

Enable subpages in a namespace

Further information: Manual:$wgNamespacesWithSubpages

To enable for instance subpages for the namespace Template:

# Enable subpages in the template namespace
$wgNamespacesWithSubpages[NS_TEMPLATE] = true;

Use short URL

Further information: Manual:Short URL, Manual:Short URL/wiki/Page title -- no root access, Rewrite engine

Converting the address (MediaWiki is located in the directory /w)

http://YOUR-DOMAIN.org/w/index.php?title=Main_page
http://YOUR-DOMAIN.org/wiki/Main_page

(1) LocalSettings.php

The first path should be already present, while the second has to be added.

$wgScriptPath       = '/w';         # Path to the actual files.
# Short article path
$wgArticlePath      = '/wiki/$1';  # Virtual path. This directory MUST be different from the one used in $wgScriptPath
$wgUsePathInfo      = true;        # Enable use of pretty URLs

(2) .htaccess (This file you need to create in the directory, where the directory /w is located)

# Forwarding of: http://YOUR-DOMAIN.org/w/index.php?index.php?title=ARTICLE
# to:            http://YOUR-DOMAIN.de/wiki/ARTICLE
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ /w/index.php [PT,L,QSA]
RewriteRule ^/*$ /w/index.php [L,QSA]

(3) robots.txt (This file you need to create in the directory, where the directory /w is located)

User-agent: *
Disallow: /w/
Disallow: /wiki/Special:Search
Disallow: /wiki/Special:Random

Activate file upload

Further information: Manual:Image Administration

(1) Set $wgEnableUploads to true:

$wgEnableUploads    = true;

(2) And if necessary use $wgFileExtensions to add a file type:

# Add one file type to the default array
$wgFileExtensions[] = 'pdf';

# Add multiple data types to the default array:
$wgFileExtensions = array_merge( $wgFileExtensions, array( 'pdf', 'ppt' ) );
 
# Overrides the default settings:
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'ppt', 'pdf' );

(3) Now you can upload files on the page Special:Upload. There you will find an explanantation of how to include a file into an article. All upload files you find on the Special:ListFiles page.

SVG

Further information: SVG

Special case: Web hosting

In the following it comes to the special case when you do not have administrative rights to your webspace.

  • Download MediaWiki-svgconvert and save the file convert.sh on your webspace
  • Download also Binary, which can be found on the page under Downloads
  • Copy the file svgconvert into the same directory as the file convert.sh
  • (MediaWiki) Add to the LocalSettings.php
## SVG settings
$wgFileExtensions[] = 'svg';
$wgAllowTitlesInSVG = true;
$wgSVGConverterPath = '$wgScriptPath/test'; # Must be adjusted, here the files are in the directory /test
$wgSVGConverters['svgconverter'] = '$path/convert.sh $input $output $width $height';
$wgSVGConverter     = 'svgconverter';

Set copyright

Further information: Setting copyright for the site

The license can be set or change due the following lines:

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "http://creativecommons.org/licenses/by/3.0/";
$wgRightsText = "Creative Commons Attribution 3.0 License";
$wgRightsIcon = "{$wgStylePath}/common/images/cc-by.png";

Open external links in a new window

Further information: Manual:$wgExternalLinkTarget

Add to the LocalSettings.php file:

$wgExternalLinkTarget = '_blank';

Design

Further information: Manual:$wgLogo

To change the logo add or change the following line in the LocalSettings.php file:

## The relative URL path to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo = "$wgScriptPath/FOLDER/EXAMPLE-LOGO.png";

Favicon

Further information: Manual:$wgFavicon

Copy your graphic file as favicon.ico in the root directory of your wiki. The graphic size should be 16 x 16 or 32 x 32 pixels. Add the following line to the LocalSettings.php file:

# Favicon
$wgFavicon = "$wgScriptPath/favicon.ico";

Hide personal tool links for anonymous visitors

Further information: Manual:$wgShowIPinHeader

To hide the personal tool links, i.e. the links to the user page and user talk page, for not logged in user (IP address is shown), set:

# Show personal tool links for anonymous visitor
# Note: If $wgUseFileCache is enabled, $wgShowIPinHeader is automatically set to false.
$wgShowIPinHeader = false;

See also

External links