「ヘルプ:Templates」を編集中
この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
1行目: | 1行目: | ||
− | <languages /> | + | <languages/> |
{{TNT|PD Help Page}} | {{TNT|PD Help Page}} | ||
<translate> | <translate> | ||
<!--T:1--> | <!--T:1--> | ||
− | If you have standard texts you want to include on several pages, the MediaWiki template feature comes into play | + | If you have standard texts you want to include on several pages, the MediaWiki template feature comes into play. |
− | |||
− | |||
− | |||
== Creation == <!--T:2--> | == Creation == <!--T:2--> | ||
50行目: | 47行目: | ||
<translate> | <translate> | ||
<!--T:16--> | <!--T:16--> | ||
− | * <code><nowiki>{{subst:Name}}</nowiki></code> — when this template link is used, it will be replaced once and for all with the content of <nowiki>[[Template:Name]]</nowiki> as of the time the page with the link is '''saved''': a copy of the contents of <nowiki>[[Template:Name]]</nowiki> will be ''substituted'' for the template link. The contents are then a part of the including page, and can be edited normally, separately from the original. ''Note'': | + | * <code><nowiki>{{subst:Name}}</nowiki></code> — when this template link is used, it will be replaced once and for all with the content of <nowiki>[[Template:Name]]</nowiki> as of the time the page with the link is '''saved''': a copy of the contents of <nowiki>[[Template:Name]]</nowiki> will be ''substituted'' for the template link. The contents are then a part of the including page, and can be edited normally, separately from the original. ''Note'': changes to the source template page will ''not'' be propagated to the page with the template link. |
</translate> | </translate> | ||
<translate> | <translate> | ||
96行目: | 93行目: | ||
<!--T:30--> | <!--T:30--> | ||
− | The thank you note will have a reason (in this case, "all your effort") and a signature ("Me"). Your objective is that any user | + | The thank you note will have a reason (in this case, "all your effort") and a signature ("Me"). Your objective is that any user is able to thank any other user, for any reason whatsoever. |
<!--T:31--> | <!--T:31--> | ||
So that the note will look similar everywhere it is used, you can define a template called [[Template:Thankyou]], for example. Although the note should look similar whenever a user thanks another user, its specific contents (i.e. the reason and the signature) will be different. For that reason, you should pass them as parameters. If we ignore the remaining elements to format the box and place the image, the core content of the template will be this: | So that the note will look similar everywhere it is used, you can define a template called [[Template:Thankyou]], for example. Although the note should look similar whenever a user thanks another user, its specific contents (i.e. the reason and the signature) will be different. For that reason, you should pass them as parameters. If we ignore the remaining elements to format the box and place the image, the core content of the template will be this: | ||
− | |||
− | + | <!--T:32--> | |
− | + | <pre><nowiki>'''A little thank you...''' | |
− | '''A little thank you...''' | ||
for {{{1}}}. | for {{{1}}}. | ||
− | hugs, {{{2}}}</ | + | hugs, {{{2}}}</nowiki></pre> |
− | </ | ||
− | |||
<!--T:33--> | <!--T:33--> | ||
Notice the use of <tvar|1><code><nowiki>{{{1}}}</nowiki></code></> and <tvar|2><code><nowiki>{{{2}}}</nowiki></code></>. This is the way to identify, within templates, the parameters that will be passed in when the template is used. Note that, within the template, each parameter is surrounded by '''three''' braces: <tvar|braces><code><nowiki>{{{ }}}</nowiki></code></>. This is different from normal template name usage. | Notice the use of <tvar|1><code><nowiki>{{{1}}}</nowiki></code></> and <tvar|2><code><nowiki>{{{2}}}</nowiki></code></>. This is the way to identify, within templates, the parameters that will be passed in when the template is used. Note that, within the template, each parameter is surrounded by '''three''' braces: <tvar|braces><code><nowiki>{{{ }}}</nowiki></code></>. This is different from normal template name usage. | ||
144行目: | 137行目: | ||
<!--T:44--> | <!--T:44--> | ||
'''Note:''' identifying parameters by order (with <code><nowiki>{{{1}}}</nowiki></code>, etc) works ''only'' with anonymous parameters. If your page identifies any parameter by number or name, as shown below, this method will no longer be available to the template which receives them. | '''Note:''' identifying parameters by order (with <code><nowiki>{{{1}}}</nowiki></code>, etc) works ''only'' with anonymous parameters. If your page identifies any parameter by number or name, as shown below, this method will no longer be available to the template which receives them. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Numbered parameters === <!--T:45--> | === Numbered parameters === <!--T:45--> | ||
205行目: | 189行目: | ||
<!--T:61--> | <!--T:61--> | ||
Since no parameters were passed in, the template presents the parameters themselves, instead of their respective values. In these cases, it may be useful to define ''default'' values for the parameters, i.e. values that will be used if no value is passed in. For example, if the template contents are changed to: | Since no parameters were passed in, the template presents the parameters themselves, instead of their respective values. In these cases, it may be useful to define ''default'' values for the parameters, i.e. values that will be used if no value is passed in. For example, if the template contents are changed to: | ||
− | |||
− | + | <!--T:62--> | |
− | + | <pre><nowiki>'''A little thank you...''' | |
− | '''A little thank you...''' | ||
for {{{reason|everything}}}. | for {{{reason|everything}}}. | ||
− | hugs, {{{signature|Me}}}</ | + | hugs, {{{signature|Me}}}</nowiki></pre> |
− | </ | ||
− | |||
<!--T:63--> | <!--T:63--> | ||
then <code><nowiki>{{{reason|everything}}}</nowiki></code> defines that if no parameter <code>{{{reason}}}</code> is provided, then the value <code>everything</code> will be used. Similarly, <code><nowiki>{{{signature|Me}}}</nowiki></code>, defaults parameter <code>{{{signature}}}</code> to value <code>Me</code>. Now, transcluding the template again without passing any parameter, results in the following: | then <code><nowiki>{{{reason|everything}}}</nowiki></code> defines that if no parameter <code>{{{reason}}}</code> is provided, then the value <code>everything</code> will be used. Similarly, <code><nowiki>{{{signature|Me}}}</nowiki></code>, defaults parameter <code>{{{signature}}}</code> to value <code>Me</code>. Now, transcluding the template again without passing any parameter, results in the following: | ||
220行目: | 200行目: | ||
<!-- strictly speaking, this example is false, because the template call was changed to obtain the desired effect - but the effect is the same if the template is defined as described --> | <!-- strictly speaking, this example is false, because the template call was changed to obtain the desired effect - but the effect is the same if the template is defined as described --> | ||
<translate> | <translate> | ||
− | <!--T: | + | <!--T:64--> |
{{Thankyou|reason=everything|signature=Me}} | {{Thankyou|reason=everything|signature=Me}} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Control template inclusion == <!--T:65--> | == Control template inclusion == <!--T:65--> | ||
306行目: | 233行目: | ||
<!--T:74--> | <!--T:74--> | ||
− | Everything outside <tvar|noinclude><code><nowiki><noinclude></nowiki></code></> and <tvar|includeonly><code><nowiki><includeonly></nowiki></code></> is processed and displayed normally; that is, both when the template page is being viewed directly and when the template is included in another page | + | Everything outside <tvar|noinclude><code><nowiki><noinclude></nowiki></code></> and <tvar|includeonly><code><nowiki><includeonly></nowiki></code></> tags is processed and displayed normally; that is, both when the template page is being viewed directly and when the template is included in another page. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Organizing templates == <!--T:75--> | == Organizing templates == <!--T:75--> | ||
333行目: | 242行目: | ||
<!--T:77--> | <!--T:77--> | ||
To find them, users can: | To find them, users can: | ||
− | # Click ''' | + | # Click '''{{int:specialpages}}''' > '''{{int:allpages}}''' |
− | # In the ''' | + | # In the '''{{int:namespace}}''' list, choose '''Template''' and click '''{{int:allpagessubmit}}'''. |
<!--T:78--> | <!--T:78--> | ||
349行目: | 258行目: | ||
<!--T:80--> | <!--T:80--> | ||
Then, an editor can simply copy and paste the example to use the template. | Then, an editor can simply copy and paste the example to use the template. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Copying from one wiki to another == <!--T:81--> | == Copying from one wiki to another == <!--T:81--> | ||
376行目: | 271行目: | ||
<translate> | <translate> | ||
<!--T:85--> | <!--T:85--> | ||
− | # Go to | + | # Go to [[Special:Export]] on the original wiki, and download an .xml file with the complete history of all necessary templates, as follows: |
</translate> | </translate> | ||
<translate> | <translate> | ||
384行目: | 279行目: | ||
<translate> | <translate> | ||
<!--T:87--> | <!--T:87--> | ||
− | #* Check the box " | + | #* Check the box "{{int:export-templates}}". |
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:88--> | <!--T:88--> | ||
− | #* '''Uncheck''' the box " | + | #* '''Uncheck''' the box "{{int:exportcuronly}}". |
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:89--> | <!--T:89--> | ||
− | #* Click " | + | #* Click "{{int:export-submit}}". |
</translate> | </translate> | ||
<translate> | <translate> | ||
407行目: | 302行目: | ||
<!--T:115--> | <!--T:115--> | ||
− | This will copy the entire code necessary, and will suffice for some templates | + | This will copy the entire code necessary, and will suffice for some templates. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Extensions === <!--T:100--> | === Extensions === <!--T:100--> | ||
429行目: | 318行目: | ||
<!--T:105--> | <!--T:105--> | ||
− | # Look for the use of CSS classes (text like <code>class="foobar"</code>) in the template text. If those classes appear in "MediaWiki:Common.css" or "MediaWiki:Monobook.css" on the original wiki, copy those classes to "MediaWiki:Common.css" on the new wiki and check if the template is now fine. | + | # Look for the use of CSS classes (text like <code>class="foobar"</code>) in the template text. If those classes appear in "MediaWiki:Common.css" or "MediaWiki:Monobook.css" on the original wiki, copy those classes to "MediaWiki:Common.css" on the new wiki and check if the template is now fine. |
− | + | ||
<!--T:106--> | <!--T:106--> | ||
# If the copied template is still not working as expected, check if there is code in "MediaWiki:Common.js" or "MediaWiki:Monobook.js" on the original wiki. If so, you can try copying it to "MediaWiki:Common.js" on the new wiki. Normally, it is a good idea to only copy code from trusted sources, and first browsing the code to identify and select the parts that are relevant. You may find comments that can serve as clues to identify the functionality of each part. | # If the copied template is still not working as expected, check if there is code in "MediaWiki:Common.js" or "MediaWiki:Monobook.js" on the original wiki. If so, you can try copying it to "MediaWiki:Common.js" on the new wiki. Normally, it is a good idea to only copy code from trusted sources, and first browsing the code to identify and select the parts that are relevant. You may find comments that can serve as clues to identify the functionality of each part. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== See also == <!--T:107--> | == See also == <!--T:107--> | ||
− | |||
− | |||
− | |||
<!--T:108--> | <!--T:108--> | ||
− | * | + | * [[Special:MyLanguage/Help:External searches]] – a template special use case example |
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:109--> | <!--T:109--> | ||
− | * | + | * [[Special:MyLanguage/Help:Magic words]] – fancy stuff you may find in some templates |
+ | </translate> | ||
+ | <translate> | ||
+ | <!--T:110--> | ||
+ | * [[Special:MyLanguage/Help:Parser functions in templates]] | ||
</translate> | </translate> | ||
− | |||
<translate> | <translate> | ||
<!--T:111--> | <!--T:111--> | ||
− | * | + | * {{meta|Help:Template}} – contains a much more thorough manual on how exactly templates function |
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:112--> | <!--T:112--> | ||
− | ** | + | ** {{meta|Help:Advanced templates}} – describes even more advanced techniques such as dynamic template calls and variable variables |
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:113--> | <!--T:113--> | ||
− | * | + | * {{meta|Help:Embed page}} – embedding pages from [[Special:MyLanguage/Help:Namespaces|namespaces]] other than <code>Template:</code>. |
</translate> | </translate> | ||
− | |||
− | [[Category:Help{{ | + | [[Category:Help{{langcat|Templates}}|Templates]] |
[[Category:Template{{translation}}]] | [[Category:Template{{translation}}]] | ||
− |