Extension:IfTemplates

From MediaWiki.org
Jump to navigation Jump to search

Other languages:
Deutsch • ‎English • ‎català • ‎dansk • ‎español • ‎italiano • ‎polski • ‎português • ‎português do Brasil • ‎sicilianu • ‎suomi • ‎中文 • ‎日本語
MediaWiki extensions manual
Crystal Clear action run.svg
IfTemplates
Release status: beta
Implementation Parser function
Description Tests if a given page contains only template calls
Author(s) Ike Hecht (tosfostalk)
Latest version 0.1 (2014-05-22)
MediaWiki > 1.21, likely earlier versions as well
PHP 5.3+
Database changes No
License GPL
Download
Hooks used
ParserFirstCallInit
Translate the IfTemplates extension if it is available at translatewiki.net
Check usage and version matrix.

The IfTemplates extension adds a parser function that tests if a given page contains only template calls. This can have a number of uses. For example, in your wiki you may be able to make the assumption that any pages that only contain template calls are stubs with no real content.

Installation[edit]

  • Download and place the file(s) in a directory called IfTemplates in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/IfTemplates/IfTemplates.php";
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage[edit]

The extension's usage is similar to the #ifexist parser function. It takes an input string, interprets it as a page title, and returns one of two values depending on whether or not the page contains only templates.

{{#iftemplates: page title | value if only templates | value if doesn't exist or has non-template text }}

The function evaluates to true if the page exists & contains only templates. Otherwise it evaluates to false. Note that if the page exists but contains no template calls, it evaluates to false.

Warning Warning: This is an expensive parser function and may not function correctly if called too many times on one page.Please see this page for more information.