User:Stefahn/Docu

On this page I collect useful stuff for running great MediaWiki websites :)

(This page is ever-growing)

MediaWiki Docu

 * Manual:FAQ
 * Manual
 * Book "Working with MediaWiki" (by Yaron Koren): workingwithmediawiki.com
 * List of configuration variables
 * Lots of advice: http://wiki.laub-home.de/wiki/MediaWiki (German)
 * Mailinglist of new MediaWiki versions
 * Commoncraft explains how Wikipedia works

SEO

 * Lots of tips & tricks (German)
 * Optional: Set some links to be follow (no nofollow) (German)
 * Thread:Project:Support desk/SEO question: Removing "wiki" from domain
 * To read:
 * http://www.richardcarterconsultancy.com/2012/07/5-tips-to-improve-your-mediawiki-sites-seo/
 * http://bundu.hubpages.com/hub/Give-your-MediaWiki-Installation-an-SEO-optimisation-and-add-Advertising
 * http://blog.säsongsmat.nu/2012/07/31/adding-authorship-information-to-mediawiki-pages/

Short URLs
RewriteRule ^wiki/(.*)$ /mediawiki/index.php?title=$1 [PT,L,QSA] RewriteRule ^wiki/*$ /mediawiki/index.php [L,QSA] RewriteRule ^/*$ /mediawiki/index.php [L,QSA]
 * very important!
 * Docu: Short URL
 * What I use in my .htaccess files:
 * Last line redirects domain.com to domain.com/wiki/Mainpage

Updating / Debugging

 * Version lifecycle - Information about MW Versions - including info about Long term support (LTS)
 * Web updater:  (more info)

If you get an empty page, chances are there is a fatal PHP error: error_reporting( -1 ); ini_set( 'display_errors', 1 );
 * Add the following in LocalSettings.php to turn on error messages:
 * For more info see Manual:How to debug
 * Another proposed way:

Extensions

 * See also my site User:Stefahn/Extensions
 * Cite: It's okay to use and define foo only later.

Useful extensions

 * 100 most popular MW extensions
 * Extensions in use on my site Secret Wiki
 * Show a list of users who have contributed to an article:
 * Extension:Contributors: used often, works after this and this hack, in includable version contributors are sorted by edits, but not linked and there is no number of edits -> managed to hack the code so that users are linked and number of edits are shown :)
 * Extension:Contribution_Credits: ordered by username, stable, used 6 times (works!), managed to remove certain usernames by hacking extension
 * Extension:Uniwiki_Authors: old, unordered list, hack to show only users who contributed certain number of bytes, according to Wikipiary: not used
 * Extension:PageBy: excludes bots and anons, ordered by edits?, very old, used 6 times (but couldn't see it on two of those wikis)
 * Extension:AuthorInfo: limit number of shown users, not used, code completely outdated
 * Extension:Semantic_Extra_Special_Properties: unordered, output as a property (I can adapt it via ask function)

Failed extensions
Extensions I tried and didn't find to be useful (so far).

Hooking / Building custom extensions

 * Extensions_FAQ
 * Available_hooks
 * To insert HTML on edit pages only: Manual:Hooks/EditPage::showEditForm:fields (maybe there's a better hook, but it works with this one)
 * If custom hook doesn't work: Check if custom php file is included in LocalSettings.php first ;)
 * How to render wikitext in one's extension -  doesn't seem to work in my "usual" extensions (not special pages)

Ways to add HTML output
Don't quote me on that, I might be wrong / not completely right.

If OutputPage object is passed to function
 * Use  in function definition, like.
 * Then use one of the following:

If OutputPage object is not passed to function
 * Use:
 * Then use one of the following:

Templates

 * See which pages include a certain template: Navigate to template and hit "What links here" (in the toolbox)
 * Use "|" as an screen output in templates: " &amp;#124; ", Example
 * Use table in template: with Template:!, Example
 * String templates: w:Template:String_templates_see_also_text

Parameters

 * How to use parameters in templates: Template
 * When applying ParserFunctions to template parameters, a pipe symbol ("|") may be used - see Help:Parser functions in templates
 * Only output parameter if it's non empty:

Including
Go the page, click on "What links here" and "Hide Links" and "Hide redirects". Then one can see the transclusions easily.
 * If the source is in the Template namespace, just use the name itself, alone:
 * If the source is in the Main article namespace, you must put a colon in front of the name, thus:
 * If the source is in any other namespace (e.g., "User:Example"), you must use the full name, including the namespace, thus:
 * Noinclude, includeonly, onlyinclude:
 * noinclude: displayed only when the template page is being viewed directly; will not be included; useful for a description how to use the template and for
 * includeonly: displayed only when the page is being included. Useful for adding all pages containing a given template to a category, but not the template itself.
 * onlyinclude: only text surrounded by "onlyinclude" markup should be transcluded onto another page. It often overrules the other include tags: If there is at least one pair of "onlyinclude" tags on a page, then whenever this page is transcluded, it is only the material within the "onlyinclude" tags which gets transcluded.
 * If you want to know on which pages you've included a certain other page (with ):

Skins / CSS

 * To change the way MediaWiki pages print, you put CSS into MediaWiki:Print.css on your wiki.
 * All stylesheets MW uses: Manual:Interface/Stylesheets
 * Manual:Interface

Sidebar-Tricks

 * Highlight a sidebar entry:
 * Add picture before sidebar entry:
 * Show a certain entry (or a group of entries) only to a certain user group:
 * Add to your Common.css:


 * Add to MediaWiki:Group-groupname.css (for example for bureaucrats: MediaWiki:Group-bureaucrat.css):

Cool skins
'''Favorites:
 * Vector skin with fixed width, boxed layout and big header: http://telefonanbieter-wechseln.org (CSS code to follow)
 * http://foreground.wikiwonders.net
 * Puts your content in the foreground (will be used as default skin on http://wikiapiary.com soon)
 * inherently responsive for mobile thanks to Foundation
 * User:Thingles on responsiveness: However, responsiveness on a wiki is such a tricky thing since the editors have a ton of control over it. CSS changes can make it non-responsive. Also, any template that uses tables can break responsiveness. In short, the skin enables it but the wiki must play along.
 * http://paulgu.com/wiki/Mediawiki_Skins - Used to used it myself on http://geld-verdienen-wiki.de
 * Vector skin with horizontal menu and drop down: http://www.baldursgatewiki.com/wiki/MediaWiki:Vector.css (make sure to set  in LocalSettings.php for the drop down menu to work)

'''Other cool skins:
 * http://energypedia.info - uses Iswiki skin developed by http://idea-sketch.com (my guess)
 * http://practicalplants.org/wiki/Practical_Plants
 * http://docs.webplatform.org
 * http://sunshinereview.org/index.php/Portal:WikiFOIA
 * http://www.whoinspired.com/
 * http://gomediawiki.com/wiki/Free_wiki_skin (Example: critical-mass-rides.co.cc)
 * Skin:Erudite
 * Nimbus_skin - Example: http://www.halopedia.org/
 * http://filament.wikiwonders.net/
 * https://sellfy.com/p/VRjA/

'''Learn skinning:
 * Manual:Skinning/Tutorial
 * German skin docu on WikiPedia: w:de:Wikipedia:Technik/Skin
 * http://www.earlgreyandbattenburg.co.uk/books/mediawiki-skins-design/
 * http://blog.blue-spice.org/2012/10/01/mediawiki-skins-a-visual-feast/

'''Ideas:
 * http://www.wikipediaRedefined.com/

Mobile skins

 * Extension:MobileFrontend
 * WPTouch
 * Simple_mobile_skin_auto_change
 * Use other skin for mobile devices (German)
 * How to use mobile theme of Wikipedia (German)

Show content only to logged-in users
Ways to show content only to logged-in users and not to anons ("show" means "print on screen"):

Working solution: CSS

In MW 1.16.2 I used this code to load a custom CSS sheet (in my PHP skin file) - this code still works with 1.19.2:

Create a file "anon.css" (in the skins/vector directory) and add:

Then in your wikitext add the following class if you don't want to show content to anons (that means if you want to show content only to logged-in users):

Working solution: Extension:UserFunctions

Use parser function.

Possible solution: common.js (not working for me) use something like your wikitext ; in MediaWiki:common.css add: .anononly { display: none; } and in MediaWiki:common.js add if ( !mw.user.isAnon ) { $( '.anononly' ).removeClass( 'anononly' ); }

Tried it and failed - tried the example shown here and replaced isanon with anonymous (since I used 1.19.2) but still no message.

Possible solution: user group CSS

One can load a CSS file for certain user groups via Manual:User_group_CSS_and_Javascript - this works fine for all user groups except for anons (see this discussion).

User group CSS file seems to be case sensitive (I had to name the file MediaWiki:Group-Mitschreiber.css instead of MediaWiki:Group-mitschreiber.css to get it working).

Show content only to a certain group (in PHP files)
The following worked for me - I added this code in my skin PHP file:

Discussions & Watch/Unwatch

 * Edit watchlist: Special:EditWatchlist, in German Spezial:Beobachtungsliste_bearbeiten
 * If a watched page is moved, the old and the new are watched after the move (result of a test by myself).
 * If you want to hide edits from other users (so that they don't get a mail notification about it): Check "minor edit" when saving ("Replace all" uses this minor edit too) and make sure the users don't have the checkmark in "E-mail me also for minor edits of pages and files" (also see Thread:Project:Support desk/Hide (bot) edits from other users)

Liquid Threads

 * Namespaces that LQT adds: Extension_default_namespaces
 * How to prevent anons from using LiquidThreads
 * '''Header
 * If a LQT thread is started in a discussion page, the LQT header seems to be generated (red "Kopfbereich ergänzen" changes to "Bearbeiten Versionen Löschen")
 * If one adds LQT to a page, the Edit and Delete links at the top disappear. You can find them in the LQT header (Discussion).
 * There are 2 user preferences (see Manual:$wgDefaultUserOptions at the very end of the table):
 * lqt-watch-threads: Selbst erstellte oder von mir bearbeitete Themen beobachten (true by default)
 * lqtnotifytalk: Bei Antworten zu beobachteten Themen E-Mails senden (false by default)
 * Problems (with 2.0 alpha):
 * lqt-watch-threads works - but after replying to a thread you have to refresh the page (clear cache) to see "unwatch" instead of "watch" (if you start a new thread it works just fine).

Parser functions
):
 * Documentation for parser function #if: Help:Extension:ParserFunctions
 * #if and tables: To prevent empty paragraphs and breaks, use this code (notice the
 * usual cells
 * without if
 * without if
 * Add references tag plus heading automatically if a ref tag is entered? Help_talk:Extension:ParserFunctions, Solution: Thread:Project:Support_desk/_How_to_use_within_parser_function%3F

Misc

 * MediaWiki has a CMS marketshare of 0,2 %.
 * A better diff tool that recognizes if a wikitext block was only moved: http://www.mediawiki.org/wiki/Thread:Project:Support_desk/Better_diff_tool%3F#Better_diff_tool.3F_18763
 * If you use Sitenotice chances are Google will show the sitenotice text instead of the page content in the SERPs. Use no index for the sitenotice (?).
 * Allow HTML:
 * When $wgRawHtml=true, the wiki will allow raw unchecked HTML in ... sections
 * You can't set group permissions to allow some to use raw HTML and some to not use it.
 * Better solution: Extension:Secure HTML
 * Permissions
 * Thread:Project:Support desk/Bureaucrat can degrade sysop!?
 * Blog article about User engagement: http://blog.wikimedia.org/2013/02/22/onboarding-results/, Suggest Bot: https://en.wikipedia.org/wiki/User:SuggestBot
 * Searching:
 * Some search operations
 * Eliminating Wiki Markup from Search Results
 * List of Magic Words
 * Messages / Language
 * If you want to see system messages in another language add  to the URL (for english use   for example)
 * You can find the message you want to change by adding  to the URL.
 * Sitemap:
 * Generate Sitemap via shell: http://wiki.laub-home.de/wiki/Mediawiki_Sitemap_erstellen (German)
 * Copyright:
 * MediaWiki:Copyright is shown only if $wgRightsText is set (also works if one uses )
 * Log in / Accounts:
 * If admin creates a user account (for someone else): Benutzerkonto anlegen = use PW that was entered before, Per E-Mail = use random PW and mail it to new user
 * Account names are case sensitive.
 * Tables
 * Zebra (alternating colors) and highlighting: http://de.wikipedia.org/wiki/Hilfe:Tabellen#zebra
 * Working zebra CSS:
 * Images
 * Turn off link:  (see also Help:Images)
 * Issues with thumbnails in 1.19.x: Thread:Talk:MediaWiki 1.19/Thumbnails didn't work since Update to 1.19/reply (32)

Security

 * Make a mirror of your wiki: http://wiki.laub-home.de/wiki/Mediawiki_Mirror_Skript (German)

TOC / Headlines

 * Making a heading that does not show up in TOC: http://meta.wikimedia.org/wiki/Help:Section#Making_a_heading_that_does_not_show_up_in_ToC - alternative: http://en.wikipedia.org/wiki/Template:Fake_heading
 * anywhere on the page will remove the edit links.

jQuery

 * jQuery has been introduced in MediaWiki core as of MediaWiki 1.16 and is loaded by default on every page as of 1.17 (see JavaScript).
 * One doesn't find any "jquery" term within the source code of the page though.
 * Add jquery ready function to Mediawiki:Common.js - without script tags - just write $(document).ready(function {

Categories

 * Hide Categories by adding  to category page (see Help:Categories)
 * Showing number of pages in subcategories (instead of number of subcats)
 * Hiding certain pages in categories is not possible (see here).
 * Help:Categories says: "It is a good idea to organize all categories into a hierarchy with a single top level category." See also this support thread.
 * Thread:Project:Support desk/Random page from certain category?

Linking

 * Linking between Wikis: http://meta.wikimedia.org/wiki/Help:Interwiki_linking, Link on german wikipedia: Artikel
 * Template:Softredirect
 * To display a link without the arrow icon, place the external link syntax between  tags.
 * Linking to user's user page:
 * Manual:Redirect_to_the_user's_user_page
 * Manual:Redirect_to_the_user's_user_page

Caching

 * Caching on SMW: http://semantic-mediawiki.org/wiki/FAQ#Why_doesn.27t_data_I_have_just_added_show_up_in_queries.3F
 * Only single page:
 * http://www.mwusers.com/forums/showthread.php?15954-Is-it-possible-to-disable-cache-for-a-particular-page
 * worked for me (1.19.2): Extension:Winter with

Database

 * To keep database size small the contents of objectcache table may be deleted (delete only the contents of this table, no other one!) - see http://www.mediawiki.org/wiki/Manual:Objectcache_table and http://www.mediawiki.org/wiki/Thread:Project:Support_desk/How_to_use_only_small_images_from_commons.wikimedia.org%3F#How_to_use_only_small_images_from_commons.wikimedia.org.3F_16262

Editing & Wikitext

 * Text Editor support
 * How to do syntax highlighting in WikiEditor: wikEd

Some special wikitext:
 * = horizontal rule
 * = show code in PHP highlighting (requires Extension:SyntaxHighlight GeSHi)

Connecting WordPress with MediaWiki
Single Sign-On
 * Use Extension:WPMW
 * If WordPress (WP) is not installed in a higher level folder but in the same folder as MediaWiki (MW) use this WordPress plugin to fix cookie problems

Run MW and WP on the same domain (without subdomains)

Say you want your wiki to be located at example.com/wiki and at the same time you want your WordPress pages to be at example.com/word and example.com/press - and: the homepage example.com should be also a WordPress page.

This worked for me: RewriteEngine On RewriteRule ^wiki/(.*)$ /mediawiki/index.php?title=$1 [PT,L,QSA] RewriteRule ^wiki/*$ /mediawiki/index.php [L,QSA] RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
 * Install MediaWiki in folder root/mediawiki and WordPress in root/wordpress.
 * In WP Dashboard -> Settings -> General set the following:
 * WordPress Address (URL): http://domain.com/wordpress (should be set to this already by the installation)
 * Site Address (URL): http://domain.com/
 * Copy the index.php from root/wordpress to root/ and change the line  to   (see also )
 * Now comes the magic: Copy the content of root/wordpress/.htaccess and generate the following .htaccess file in root/ :
 * 1) BEGIN MediaWiki
 * 1) for Short Wiki URL:
 * 1) To redirect all users to access the site WITHOUT the www. prefix,
 * 2) (http://www.example.com/... will be redirected to http://example.com/...)
 * 3) adapt and uncomment the following:
 * 1) END MediaWiki

 RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule. /index.php [L]  $wgScriptPath      = "/mediawiki"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
 * 1) Copy the content of root/wordpress/.htaccess and add it below:
 * 2) BEGIN WordPress
 * 1) END WordPress
 * Make sure that you do not add a line like the  since this would forward the homepage to your wiki (we don't want this since we want a WordPress homepage).
 * This tutorial assumes that you use Short URLs for your wiki - I use the following lines in my LocalSettings.php:
 * You don't have to delete the original .htaccess file in root/wordpress/.htaccess.