Extension:PageInCat: Difference between revisions
add warning |
→Installation: update |
||
| Line 60: | Line 60: | ||
==Installation== |
==Installation== |
||
[[special:extensionDistributor/PageInCat|Download]] thingy, put it in appropriate place in extensions directory, add line <code>require_once( "$IP/extensions/PageInCat/PageInCat.php" );</code> to bottom of LocalSettings.php |
[[special:extensionDistributor/PageInCat|Download]] thingy, put it in appropriate place in extensions directory, add line <code>wfLoadExtension( 'PageInCat' );</code> (On old MW you may have to do <code>require_once( "$IP/extensions/PageInCat/PageInCat.php" );</code> instead) to bottom of LocalSettings.php |
||
This extension will work on MediaWiki 1.18 and later. (The 1.19 version on the download page will work with 1.18) |
This extension will work on MediaWiki 1.18 and later. (The 1.19 version on the download page will work with 1.18) |
||
Revision as of 18:29, 25 August 2016
Release status: stable |
|
|---|---|
| Implementation | Parser function |
| Description | Adds a parser function to test if the current page is in some category |
| Author(s) | Bawolfftalk |
| Latest version | 2 |
| MediaWiki | 1.18+ |
|
$wgPageInCatUseAccuratePreview |
|
| Licence | GPLv2 |
| Download | |
| Translate the PageInCat extension if it is available at translatewiki.net | |
What can this extension do?
This extension adds a parser function that is similar to the {{#ifexist:...}} function from extension:ParserFunctions. It works as follows {{#incat:Some category|what to do if current page is in category|what to do if current page is not in category}}. It also suports #incategory, #ifpageincat and #ifpageincategory.
Conditional category inclusion
Adding things like {{#incat:Foo||[[category:Foo]]}} (Page is a member of category Foo only if it is not a member of category Foo) is generally a bad idea (duh!). This could cause the page to alternate being in and not in the category. More generally, putting any sort of category link inside a {{#incat:...}} may cause unexpected behaviour since the extension can't tell if its in the category until after parsing the entire page. In general, for the purposes of {{#incat:...}}, we consider the categories present the first time parsing the page as the categories the page is in.
If this sort of situation is detected during a preview, the following warning is presented at the top of the page:
Warning: The category Some category was detected incorrectly by {{#incat:...}}, and as a result this preview may be incorrect. This can be caused by including categories inside of {{#incat:...}} statements, and may result in inconsistent display.
Download instructions
If you have an svn client, checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/PageInCat . Otherwise you will have to download the individual files from that link manually.
Installation
Download thingy, put it in appropriate place in extensions directory, add line wfLoadExtension( 'PageInCat' ); (On old MW you may have to do require_once( "$IP/extensions/PageInCat/PageInCat.php" ); instead) to bottom of LocalSettings.php
This extension will work on MediaWiki 1.18 and later. (The 1.19 version on the download page will work with 1.18)
Configuration parameters
- $wgPageInCatUseAccuratePreview
- Defaults to true. Controls if to use more accurate previews (aka use the categories that are in the wiki-text you are previewing instead of the last saved revision). May cause previews to take twice as much time as they normally would (This includes previewing things not using
#incatfunctions). If this is set to false, previews will often have{{#incat:..}}being evaluated incorrectly, but once the page is saved, they will be evaluated correctly. - $wgExpensiveParserFunctionLimit
- Not directly a configuration parameter of this extension, but limits the number of times you can use
#incat(and other expensive parser functions) in a page (Doing #incat twice for the same category only counts as one usage). This defaults to 100, which should be more than enough.
See also
- Extension:ParserFunctions (For more general conditional constructs)
- Extension:CategoryTests (Didn't know CategoryTests extension existed when I wrote this one. The main difference seems to be that PageInCat will always try to use categories from the current revision, while CategoryTests may sometimes use the categories from the previous revision, which could result in unexpected page content)
- Extension:CategoryFunctions
- Pages using Template:Extension with unknown parameters
- Stable extensions
- Parser function extensions
- ParserFirstCallInit extensions
- ParserClearState extensions
- ParserAfterTidy extensions
- EditPageGetPreviewText extensions
- ParserBeforeInternalParse extensions
- Extensions with unknown license
- Extensions in Wikimedia version control
- All extensions
- Category extensions
