查看“模板:Exists/doc”的源代码
来自Ubuntu中文
←
模板:Exists/doc
跳到导航
跳到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> 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: <nowiki>{{</nowiki>exists | page=''page'' | then=''result if page exists'' | else=''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'' }} If the page name may contain equals signs, always use the "<code>1=</code>" or "<code>page=</code>" prefix. 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. With #ifexist this can be avoided, and with the CSS method it is not the case. If the page to be transcluded does not exist, then link brackets are put around the full pagename, with the following conversions (visible with [[Special:ExpandTemplates]]): *a colon is put in front if it is not there yet *the namespace name (if applicable) and the pagename are capitalized (on most wikis) *underscores are replaced by spaces Thus <code><nowiki>{{help:qq w_x}}</nowiki></code> and <code><nowiki>{{:help:qq w_x}}</nowiki><code> both give <code><nowiki>[[:Help:Qq w x]]</nowiki></code>. For the link there is not such an automatic conversion. Therefore the template prefixes a colon to the parameter for the full pagename (it should not already start with a colon) and applies lc and anchorencode (to convert spaces to underscores) on both sides before comparison: *<code><nowiki>{{anchorencode:{{lc:[[:help:qq w_x]]}}}}</nowiki></code> gives {{anchorencode:{{lc:[[:help:qq w_x]]}}}} *<code><nowiki>{{anchorencode:{{lc:{{help:qq w_x}}}}}}</nowiki></code> gives {{anchorencode:{{lc:{{help:qq w_x}}}}}} Thus a false-positive for a non-existing page is avoided. A false-negative for an existing page is possible, but typically only for specially constructed examples. ==See also== *[[Help:Page existence]] <includeonly><!-- CATEGORIES AND INTERWIKIS HERE, THANKS --> [[Category:Miscellaneous templates|{{PAGENAME}}]] </includeonly>
该页面使用的模板:
模板:Documentation subpage
(
查看源代码
)
帮助:Qq w x
(
查看源代码
)
返回
模板:Exists/doc
。
导航菜单
页面操作
模板
讨论
阅读
查看源代码
历史
页面操作
模板
讨论
更多
工具
个人工具
登录
导航
首页
最近更改
随机页面
页面分类
帮助
搜索
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息