From mediawiki.org
Jump to navigation Jump to search
Other languages:
English • ‎Türkçe • ‎dansk • ‎español • ‎français • ‎português do Brasil • ‎中文 • ‎日本語
MediaWiki extensions manual
OOjs UI icon advanced.svg
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.29+, likely earlier versions as well
PHP 5.3+
Database changes No
License GPL
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.


  • 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:
    wfLoadExtension( 'IfTemplates' );
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


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.