Template:Exists/doc: Difference between revisions

Created page with "{{Documentation subpage}} This template tests whether a given page exists. It can be useful in view of the maximum number of ParserFunctions#.23ifexi..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
This template tests whether a given page exists. It can be useful in view of the maximum number of #ifexist calls that can be used on a page. (However, in the case of frivolous use of #ifexist which was the reason for the limit, do not replace this use with frivolous use of this template!)
This template tests whether a given page [[Help:Page existence|exists]]. It can be useful in view of the maximum number of [[ParserFunctions#.23ifexist:|#ifexist]] calls that can be used on a page. (However, in the case of frivolous use of #ifexist which was the reason for the limit, do not replace this use with frivolous use of this template!)


The full syntax for using it is:
The full syntax for using it is:


  <nowiki>{{</nowiki>exists | page=''page'' | then=''result if page exists'' | else=''result if page does not exist'' }}
  <nowiki>{{</nowiki>exists | ''page/filename'' | ''result if page exists'' | ''result if page does not exist'' }}
 
The parameters <code>then</code> and <code>else</code> are optional; if not given, the default values for <code>then</code> and <code>else</code> are ''1'' and ''0'' respectively.  The page name may alternatively be given as the first unnamed parameter, as in this short version:
 
<nowiki>{{</nowiki>exists | ''page'' }}


The method is based on transclusion of the possibly existing page. If the page does not exist the code for page transclusion produces a (red) link. Even if this result is used for comparison only, and not for final output, the page counts as being transcluded. Therefore the page appears as red link in the list of transcluded pages.
The method is based on transclusion of the possibly existing page. If the page does not exist the code for page transclusion produces a (red) link. Even if this result is used for comparison only, and not for final output, the page counts as being transcluded. Therefore the page appears as red link in the list of transcluded pages.
Line 28: Line 23:
<includeonly>
<includeonly>
[[Category:Templates|{{PAGENAME}}]]
[[Category:Templates|{{PAGENAME}}]]
</includeonly>
</includeonly><noinclude>[[Category:Template documentation]]</noinclude>