Jump to content

వికీపీడియా:Template namespace

వికీపీడియా నుండి
వికీపీడియా డేటా స్ట్రక్చర్
సబ్జెక్టు పేరుబరులు చర్చ పేరుబరులు
0 (ప్రధాన/వ్యాసం) చర్చ 1
2 వాడుకరి వాడుకరి చర్చ 3
4 వికీపీడియా వికీపీడియా చర్చ 5
6 దస్త్రం దస్త్రంపై చర్చ 7
8 మీడియావికీ మీడియావికీ చర్చ 9
10 మూస మూస చర్చ 11
12 సహాయం సహాయం చర్చ 13
14 వర్గం వర్గం చర్చ 15
100 వేదిక వేదిక చర్చ 101
118 [[వికీపీడియా:డ్రాఫ్టులు|]] 119
710 TimedText TimedText talk 711
828 మాడ్యూల్ మాడ్యూల్ చర్చ 829
రద్దైనవి
2300 [[వికీపీడియా:గాడ్జెట్|]] 2301
2302 [[వికీపీడియా:గాడ్జెట్|]] 2303
-1 ప్రత్యేక
-2 మీడియా

Wikipedia:Template messages (Changes) contains an index of the most commonly used templates.

Wikipedia:Navigation templates (Changes) contains a partial list of various subject-class navigational elements.

Introduction

[మార్చు]

Templates often look like text boxes with a different background color from that of normal text. They are in the template namespace, i.e. they are defined in pages with "Template:" in front of the name.

For example, consider the template Template:Disambiguation (follow the link to see the page where it can be edited). To insert the template's content into an article, type {{Disambiguation}} in the wiki page ("{{Disambiguation}}" is called a template tag). Every article with that tag in it will display the following text:

This technique is commonly known as transclusion. Templates can also include calculated and substituted elements, as well as parameters, allowing for complex usage. For a table of some useful templates, see Wikipedia:Template messages. For detailed templating documentation see m:Help:Template.

Names can be made up of more than one word, e.g. {{Train topics}}. The first character (only) is not case-sensitive, so {{cleanup}} and {{Cleanup}} are the same template, but {{cfd}} and {{cfD}} are not.

Templates can also accept template parameters which are then inserted into the output of the template.

Templates used in pages from the article namespace provide information to help readers. These can include navigation aids, or warnings that content is sub-standard. Templates that provide information only of service to editors belong on an article's talk page.

With the template namespace it is possible to include the contents of a page in that namespace within a page in a different namespace, using double curly braces around the template title (for example, {{title}} would import Template:Title). This is used to:

  • place recurring messages (such as those to denote stubs, disambiguation pages, etc.) into articles in a consistent manner;
  • insert boilerplate messages for various issues like copyright violation, neutrality disputes, etc., using a simple shortcut command; and
  • create navigation templates and sidebars to link series of related articles together.
  • create infoboxes
  • provide cross-language portability of texts which are largely internationally the same, but contain some standard terms different in each language; the standard terms are replaced by {{..}} referring to Template pages which have the same name but localised content in each language. This is applied for taxoboxes.

Templates should not do the work of article content in the main article namespace; instead, place the text directly into the article.

Templates should not be used to create lists of links to other articles when a category or a See also list can perform the same function.

For further instructions on using this namespace, and for more information about it, please see m:Template.

Usage in discussions

[మార్చు]

Sometimes you will want to refer to a template, rather than actually invoking it. An easy way to do this is to use the "template link" template, Template:Tl. So to discuss the Cleanup template rather than insert the template itself, typing "{{Tl|Cleanup}}" yields the result "{{Cleanup}}". This notation makes clear that you are discussing a template and gives a link to the template itself.

To include parameters in a template, use Template:Tlx, for example, {{tlx|convert|1|m}} yields the result "{{convert|1|m}}".

Instructions

[మార్చు]

New template creation

[మార్చు]

To create a new custom message, simply create a page in the Template namespace, named [[Template:]], followed by a name for the message, that contains the text of the message. Names can contain spaces, and initial case is irrelevant; note that template names are easy to remember if they follow standard English spelling, spacing, and capitalization (also see the naming conventions for articles). Try to avoid having templates whose names differ only in casing, spacing, or punctuation. To make such a page, create a link something like [[Template:My message]] on your user page or in the sandbox and then click on it. Any new high-risk templates should be semiprotected or fully protected as appropriate.

Adding a template to a page

[మార్చు]

To add a template to the page, simply type the name of the template with two braces on each side. For example, to add Template:Underlinked to a page, type {{Underlinked}}.

If a template takes a number of parameters, it can be helpful for the following layout to be used when the template is called:

{{Example template name
| first parameter  = Text of first_value
| second parameter = Text of second_value
| 3rd parameter    = Text of 3rd_parameter
| etc              = etc
}}

Putting each parameter on a separate line, with the equals signs aligned vertically, helps editors to decipher the wikicode.

Dynamic or full substitution (subst:)

[మార్చు]
Main article: Wikipedia:Substitution

There are two major ways to include custom messages, {{Your message}} and {{subst:Your message}}. {{subst:Your message}} makes a copy of the message text and places it where you put the tag after you save an article (substitution). Without "subst", the message will be loaded and put on the page every time you view it, a process known as transclusion.

In other words, when the message is updated, you do not need to update a page that uses it if you use {{Your message}}. As a guideline, short temporary messages that will be removed soon should be copied using subst (which has the advantage of showing the message in the wiki source), and standard notices that might remain on a page for months or forever should be transcluded for easy updating. (You should not use {{Your message}} for a message which contains any links which may change in the future. This method doesn't refresh "What links here" unless every article containing the {{Your message}} gets changed after the modification of the link in the message.)

If you need to edit the template message individually after you put it on your page, use subst. If you don't need to edit it, and would rather the message is automatically updated along with changes made to the template, don't use subst.

For an example of how to substitute variables at the time of their inclusion see the subst magic section in Help:Variables.

Template documentation

[మార్చు]

A template can sometimes be difficult to use by only looking at the source of the template, so you are encouraged to document your template.

There are two different ways to do this.

One alternative is to use <noinclude> to include a minor description direct into the template, for example:

'''This is a {{{1}}} article.'''<noinclude>
Place this template on any article that requires description. It 
takes one parameter, an adjective used to describe the article. 
For example, {{article-describe|bad}} produces the text, 
'''This is a bad article.'''
</noinclude>

Another alternative is to create a /doc subpage for the documentation (preferred for templates with multiple parameters etc.) and add <noinclude>{{Documentation}}</noinclude> below the actual template.

A caution about line breaks

[మార్చు]

Note that some templates may accidentally cause extra linebreaks in the rendered articles. This is especially true of infobox templates and other template boxes that usually float on the right side of an article, since the additional lines will not be seen on the template page.

As a general guideline, avoid two linebreaks together in your template. These may "add up" with other linebreaks in the article and be displayed as unwanted white space.

Sandbox for experiments

[మార్చు]

If you wish to experiment with templates (and not have your experiments deleted before you are done with them), you may do so in the Template sandbox. You may also use the templates X1, X2, X3, X4, X5, X6, X7, X8 and X9 for experimental purposes. To include a test template, use the form {{X1}} for template X1, {{X2}} for template X2, etc.

There is no real looping functionality built into the Mediawiki software as of this time (see, however, {{for loop}}), but there are some tricks for mimicking them. For instance, repeatedly calling a template that repeatedly calls a different template can mimic a double loop (see, e.g., Template:ld (backlinks edit), Template:l2d (backlinks edit), and Template:l3d (backlinks edit)). Templates can also be coerced into calling themselves (normally prohibited by the Mediawiki software past a single instance, to prevent infinite loops), by the artful use of redirects (see m:Template:Loop1 (backlinks edit))

An example where the same template is used for different loop levels is m:Template:Loop 2 (backlinks edit). Because the software has a built-in protection against infinite nesting: Fatal error: Maximum execution time of 30 seconds exceeded in /w/includes/Parser.php on line 775. A a redirect is used for each level. The number of levels that the template can handle is determined by the number of parameters specified in the two template calls it comprises (because going up a level requires an extra parameter) and the number of existing redirects.

Likewise, Template:Lanlp 1 is used for both the inner and the outer of a double loop. Adding an item (here a language) adds to each row and also adds an extra row.

Effective repetition

[మార్చు]

A technique for repetition of similar template calls without actually putting this list in the wikitext is demonstrated in template:for ( talk edit history links ), and a more primitive method described below.

Example using t2demo
[మార్చు]

(using Template:t2demo containing "start-{{{1}}}-middle-{{{2}}}-end"):

{{for loop|; |call=t2demo|pc1n=2|pc1v=constant|abc|def|ghi}} gives:

start-abc-middle-constant-end; start-def-middle-constant-end; start-ghi-middle-constant-end

Description of the old m:Template:List of template calls (backlinks edit):

For an arbitrary template with up to three nameless parameters, it is equivalent to calling the template repeatedly, with the first parameter varying, and the possible other parameters fixed: One specifies the name, the values of the fixed parameters, and the list of values the first parameter should have in consecutive template calls, with a sequential number each, and ending with "end". The technique requires redirects like m:Template:List of template calls 3 (backlinks edit), as many as the maximum number of repetitions.

If, for example, the second parameter varies, or two parameters, then a similar template can be made, but each version requires its own set of redirects.

Example (using Template:t2demo containing "start-{{{1}}}-middle-{{{2}}}-end"):

{{List of template calls|t2demo|constant||abc|1|def|2|ghi|end|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}}

gives (see the master copy m:Help:Template#Repetition within a page):

మూస:List of template calls

The empty parameters are needed in accordance with the maximum number of parameters the repeated template can have (currently three) and the maximum number of repetitions. Putting more empty parameters than needed at the end does not matter, but the number of empty parameters in the beginning of the list should be correct.

Historically, an "msg:" prefix had to be added in front of the template name when it was used on a page. For example, was typed instead of . This is no longer necessary.

In Wikipedia's first 35 months, there was no template or transclusion mechanism at all. The page Wikipedia:Boilerplate text was created in September 2002 to collect frequently used text in various Wikipedia processes. The MediaWiki namespace was introduced with MediaWiki 1.2.6 on December 6, 2003, and was used not only for the user interface but also for creating boilerplate text messages to be inserted in articles using the {{msg: ...}} syntax. This function was replaced with the Template namespace during the software upgrade to MediaWiki 1.3 on May 30, 2004. As a function of the "Template namespace initialisation script", all non-system messages were moved to the new namespace. The initialisation script also replaced MediaWiki: references in articles with Template: to bypass the redirects created by the moves.

For a short time, Wikipedia:Articles for deletion (then known as votes for deletion or VfD) used MediaWiki: messages named in the format "MediaWiki:VfD-articlename". These were moved to the Template: space in June 2004 and were named "Template:VfD-articlename". This usage is deprecated now in favor of subpages.

For an idea on where MediaWiki was in 2009 with template implementation considerations, see the discussion m:on-templates-and-programming-languages.

Searching in the template and template talk namespaces

[మార్చు]

To search in the template or template talk namespaces only, put "template:" or "template_talk:" before the search term. For example, this URL searches for "transclude" in the template namespace while this one searches for "transclude" in the template talk namespace.

It is possible to manipulate the URL to allow searching in any subset of namespaces. For example template search for regnum searches both the Template and the Template:talk namespaces for "regnum".

See Help:Searching for more information.