"模板:Namespace detect/doc" 修訂間的差異
小 (机器人添加:eo:Ŝablono:Determinas nomspacon) |
|||
行 1: | 行 1: | ||
− | {{ | + | <includeonly><!-- 在這裡加入模板的保護標識 --></includeonly> |
+ | {{Documentation subpage}} | ||
+ | {{high-use| 65,000+ }} | ||
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> | <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> | ||
行 6: | 行 8: | ||
It helps other templates detect what type of page they are on. | It helps other templates detect what type of page they are on. | ||
− | It detects and groups all the different [[ | + | It detects and groups all the different [[帮助:名字空间#Enumeration|namespaces]] used on Wikipedia into several types: |
− | :'''main''' = Main/article space, as in normal | + | :'''main''' = Main/article space, as in normal Wikipedia articles. |
:'''talk''' = Any talk space, such as page names that start with "Talk:", "User talk:", "File talk:" and so on. | :'''talk''' = Any talk space, such as page names that start with "Talk:", "User talk:", "File talk:" and so on. | ||
− | :'''user, | + | :'''user, wikipedia, file, mediawiki, template, help, category''' and '''portal''' = The other namespaces except the talk pages. |
:'''other''' = Any namespaces that were not specified as a parameter to the template. See explanation below. | :'''other''' = Any namespaces that were not specified as a parameter to the template. See explanation below. | ||
行 17: | 行 19: | ||
'''Note!''' For most usage cases it might be better to use the simpler namespace detection templates. (See the [[#See also|see also]] section below.) Since this template is more prone to human errors such as misspelling the parameter names. | '''Note!''' For most usage cases it might be better to use the simpler namespace detection templates. (See the [[#See also|see also]] section below.) Since this template is more prone to human errors such as misspelling the parameter names. | ||
− | === | + | === 用法 === |
+ | |||
This template takes one or more parameters named after the different page types as listed above. Like this: | This template takes one or more parameters named after the different page types as listed above. Like this: | ||
行 78: | 行 81: | ||
}} | }} | ||
− | === Demospace | + | === Demospace === |
− | |||
− | Demospace understands any of the page type names used by this template, including the '''other''' type. It tells the template to behave like it is on some specific type of page. Like this: | + | For testing and demonstration purposes this template can take a parameter named '''demospace'''. Demospace understands any of the page type names used by this template, including the '''other''' type. It tells the template to behave like it is on some specific type of page. Like this: |
<pre> | <pre> | ||
行 99: | 行 101: | ||
}} | }} | ||
− | + | It can be convenient to let your template understand the demospace parameter and send it on to the {{tl|namespace detect}} template. Then do like this: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | It can be convenient to let your template understand the demospace | ||
<pre> | <pre> | ||
行 124: | 行 108: | ||
| other = Other pages text | | other = Other pages text | ||
| demospace = {{{demospace|}}} | | demospace = {{{demospace|}}} | ||
− | |||
}} | }} | ||
</pre> | </pre> | ||
− | If | + | If the '''demospace''' parameter is empty or undefined then the template will detect page types as usual. |
=== Parameters === | === Parameters === | ||
+ | |||
List of all parameters: | List of all parameters: | ||
行 139: | 行 123: | ||
| other = | | other = | ||
| demospace = {{{demospace|}}} / main / talk / user / | | demospace = {{{demospace|}}} / main / talk / user / | ||
− | + | wikipedia / file / mediawiki / template / | |
− | help / category / | + | help / category / portal / other |
− | |||
}} | }} | ||
</pre> | </pre> | ||
− | Note: Empty values to the "main" ... " | + | Note: Empty values to the "main" ... "portal" parameters do have special meaning. |
=== Technical details === | === Technical details === | ||
+ | |||
+ | Namespace "Image" was renamed to "File" on 11 December 2008. This template was updated to understand both names well before that, thus it still works fine. For backwards compatibility it still understands "image" both as a parameter name, such as "image = File page text", and as a value "demospace = image". | ||
+ | |||
If you intend to feed tables as content to the numbered parameters of this template, then you need to know this: | If you intend to feed tables as content to the numbered parameters of this template, then you need to know this: | ||
− | [[Help:Template|Templates]] do have a problem to handle parameter data that contains pipes "<code>|</code>", unless the pipe is inside another template <code><nowiki>{{name|param1}}</nowiki></code> or inside a piped link <code><nowiki>[[ | + | [[Help:Template|Templates]] do have a problem to handle parameter data that contains pipes "<code>|</code>", unless the pipe is inside another template <code><nowiki>{{name|param1}}</nowiki></code> or inside a piped link <code><nowiki>[[帮助:模板|help]]</nowiki></code>. Thus templates can not handle [[帮助:表格|wikitables]] as input unless you escape them by using the {{tn|!}} template. This makes it hard to use wikitables as parameters to templates. Instead the usual solution is to use "[[Help:HTML in wikitext|HTML wikimarkup]]" for the table code, which is more robust. |
+ | |||
+ | For more technical details such as about "copying to other projects" and "CSS based namespace detection" see {{tl|main talk other}} and its talk page. | ||
+ | |||
+ | === 參見 === | ||
+ | |||
+ | {{namespace detect see also}} | ||
<includeonly> | <includeonly> | ||
− | <!-- | + | <!-- 本行下加入模板的分類 --> |
− | [[Category: | + | [[Category:維基百科元模板]] |
+ | |||
+ | <!-- 本行下加入模板的跨語言鏈接 --> | ||
+ | |||
+ | [[ar:قالب:كشف نطاق]] | ||
+ | [[ba:Ҡалып:Namespace detect]] | ||
+ | [[be:Шаблон:Namespace detect]] | ||
+ | [[be-x-old:Шаблён:Вызначэньне прасторы назваў]] | ||
+ | [[bjn:Citakan:Namespace detect]] | ||
+ | [[bn:টেমপ্লেট:Namespace detect]] | ||
+ | [[ca:Plantilla:Detecta espai de noms]] | ||
+ | [[cy:Nodyn:Namespace detect]] | ||
+ | [[dsb:Pśedłoga:Namespace detect]] | ||
+ | [[dv:ފަންވަތް:Namespace detect]] | ||
+ | [[en:Template:Namespace detect]] | ||
+ | [[eo:Ŝablono:Determinas nomspacon]] | ||
+ | [[fa:الگو:Namespace detect]] | ||
+ | [[hi:साँचा:Namespace detect]] | ||
+ | [[hif:Template:Namespace detect]] | ||
+ | [[hsb:Předłoha:Namespace detect]] | ||
+ | [[ko:틀:이름공간 검출]] | ||
+ | [[hu:Sablon:Namespace detect]] | ||
+ | [[ja:Template:Namespace detect]] | ||
+ | [[map-bms:Cithakan:Namespace detect]] | ||
+ | [[mhr:Кышкар:Namespace detect]] | ||
+ | [[mn:Загвар:Namespace detect]] | ||
+ | [[mzn:شابلون:Namespace detect]] | ||
+ | [[no:Mal:Namespace detect]] | ||
+ | [[pa:ਫਰਮਾ:Namespace detect]] | ||
+ | [[pam:Template:Namespace detect]] | ||
+ | [[pt:Predefinição:Namespace detect]] | ||
+ | [[ru:Шаблон:Namespace detect]] | ||
+ | [[sl:Predloga:Namespace detect]] | ||
+ | [[sr:Шаблон:Namespace detect]] | ||
+ | [[tt:Калып:Namespace detect]] | ||
+ | [[uk:Шаблон:Namespace detect]] | ||
+ | [[ur:سانچہ:Namespace detect]] | ||
</includeonly> | </includeonly> |
於 2013年2月20日 (三) 01:32 的修訂
40px | This is a documentation subpage for 模板:Namespace detect. It contains usage information, categories and other content that is not part of the original 模板 page. |
40x40px | 本模板已被應用於65,000+個頁面中,對其進行的修改會影響到這些頁面。請先在本模板的/sandbox或/testcases子頁面或您的用戶子頁面中測試所要進行的修改,並請考慮在應用修改前,於討論頁上進行討論。 |
This is the {{namespace detect}} meta-template.
It helps other templates detect what type of page they are on.
It detects and groups all the different namespaces used on Wikipedia into several types:
- main = Main/article space, as in normal Wikipedia articles.
- talk = Any talk space, such as page names that start with "Talk:", "User talk:", "File talk:" and so on.
- user, wikipedia, file, mediawiki, template, help, category and portal = The other namespaces except the talk pages.
- other = Any namespaces that were not specified as a parameter to the template. See explanation below.
For backwards compatibility this template also understands the old name image for file. But using image is now deprecated.
Note! For most usage cases it might be better to use the simpler namespace detection templates. (See the see also section below.) Since this template is more prone to human errors such as misspelling the parameter names.
用法
This template takes one or more parameters named after the different page types as listed above. Like this:
{{namespace detect | main = Article text | talk = Talk page text | other = Other pages text }}
If the template is on a main (article) page, it will return this:
- Article text
If the template is on any other page than an article or a talk page it will return this:
- Other pages text
The example above made the template return something for all page types. But if we don't use the other parameter or leave it empty then it will not return anything for the other page types. Like this:
{{namespace detect | file = File page text | category = Category page text | other = }}
On any pages other than file and category pages the code above will render nothing.
By using an empty parameter you can make it so the template doesn't render anything for some specific page type. Like this:
{{namespace detect | main = | other = Other pages text }}
The code above will render nothing when on mainspace (article) pages, but will return this when on other pages:
- Other pages text
Demospace
For testing and demonstration purposes this template can take a parameter named demospace. Demospace understands any of the page type names used by this template, including the other type. It tells the template to behave like it is on some specific type of page. Like this:
{{namespace detect | main = Article text | other = Other pages text | demospace = main }}
No matter on what kind of page the code above is used it will return this:
- Article text
It can be convenient to let your template understand the demospace parameter and send it on to the {{namespace detect}} template. Then do like this:
{{namespace detect | main = Article text | other = Other pages text | demospace = {{{demospace|}}} }}
If the demospace parameter is empty or undefined then the template will detect page types as usual.
Parameters
List of all parameters:
{{namespace detect | main = ... | other = | demospace = {{{demospace|}}} / main / talk / user / wikipedia / file / mediawiki / template / help / category / portal / other }}
Note: Empty values to the "main" ... "portal" parameters do have special meaning.
Technical details
Namespace "Image" was renamed to "File" on 11 December 2008. This template was updated to understand both names well before that, thus it still works fine. For backwards compatibility it still understands "image" both as a parameter name, such as "image = File page text", and as a value "demospace = image".
If you intend to feed tables as content to the numbered parameters of this template, then you need to know this:
Templates do have a problem to handle parameter data that contains pipes "|
", unless the pipe is inside another template {{name|param1}}
or inside a piped link [[帮助:模板|help]]
. Thus templates can not handle wikitables as input unless you escape them by using the start{{{in}}}end template. This makes it hard to use wikitables as parameters to templates. Instead the usual solution is to use "HTML wikimarkup" for the table code, which is more robust.
For more technical details such as about "copying to other projects" and "CSS based namespace detection" see {{main talk other}} and its talk page.
參見
便於偵測名字空間的模板群:
- {{main other}} – 用於條目模板。
- {{talk other}} – 用於討論頁模板。
- {{user other}} – 用於用戶頁模板。
- {{wikipedia other}} – 用以偵測"Wikipedia:"計畫頁面。
- {{file other}} – 用於檔案(圖像)模板
- {{template other}} – 用以偵測模板頁。
- {{help other}} – 用於幫助頁模板。
- {{category other}} – 用於分類頁模板。
- {{portal other}} – 用於主題頁模板。
更複雜的名字空間偵測模板:
- {{main talk other}} – 區分某些名字空間。
- {{main talk category other}} – 區分某些名字空間。
- {{namespace detect}} – 多功能模板。
- {{namespace detect showall}} – 超多功能模板。
- {{talkspace detect}} - 偵測不同名字空間的討論頁面。
Technical stuff:
- Wikipedia:名字空間 – Lists all the namespaces.
- Help:魔術字 – About
{{NAMESPACE}}
etc. - Help:解析器函数 – About
{{#ifeq:|||}}
etc.