Open main menu
This page is a translated version of the page Extension:IfTemplates and the translation is 39% complete.

Other languages:
English • ‎dansk • ‎español • ‎português do Brasil • ‎中文 • ‎日本語
OOjs UI icon advanced.svg
发布状态: 测试
实现 Parser function
描述 Tests if a given page contains only template calls
作者 Ike Hecht (tosfostalk)
最新版本 0.1 (2014-05-22)
MediaWiki 1.21+, likely earlier versions as well
PHP 5.3+
许可协议 GPL

The IfTemplates extension adds a parser function that tests if a given page contains only template calls. 这可以有很多应用。 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.


  • 下载文件,并将其放置在您extensions/文件夹中的IfTemplates目录内。
  • 将下列代码放置在您的LocalSettings.php的底部:
    require_once "$IP/extensions/IfTemplates/IfTemplates.php";
  •   完成 – 在您的wiki上导航至Special:Version,以验证扩展已成功安装。


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: 页面标题 | 只在模版中的值 | value if doesn't exist or has non-template text }}

The function evaluates to true if the page exists & contains only templates. 其他情况下判定为false。 Note that if the page exists but contains no template calls, it evaluates to false.

  警告: 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.