Community Central
Register
Community Central
No edit summary
m (→‎Further help and feedback: Mass editing of links)
Tag: Help
(22 intermediate revisions by 19 users not shown)
Line 1: Line 1:
'''Template substitution''' is an alternate way to embed information contained in a [[Help:templates|template]]. Substitution is performed by placing the code <code>subst:</code> between the template braces, before the template name, like this:
+
{{tocright}}'''Template substitution''' is an alternate way to embed information contained in a [[Help:Templates|template]]. Substitution is performed by placing the code <code>subst:</code> between the template braces, before the template name, like this:
   
<nowiki>{{subst:Templatename}}</nowiki>
+
:'''<code><nowiki>{{subst:Templatename}}</nowiki></code>'''
   
  +
== Process ==
This method of using templates requires the use of [[Help:Wikitext|wikitext]], so it is only available in the source mode of the editor.
 
 
Normally, when the code for a template named <code><nowiki>{{something}}</nowiki></code> is added to a page, it will still say <code><nowiki>{{something}}</nowiki></code> in the [[Help:Wikitext|wikitext]] when you next edit the page.
   
  +
[[File:Non subst template.png|thumb|400px|center|A template in the editor that has not been substituted.]]
==How does substituting work?==
 
Normally, when the code for a template named <nowiki>{{something}}</nowiki> is added to a page, it will display that template based on how it was designed at <nowiki>[[Template:Something]]</nowiki>. However, when you edit the page, you will still see <nowiki>{{something}}</nowiki> in the wiki text, instead of the full code of the template.
 
   
However, if you substitute a template, the text <nowiki>"{{subst:something}}"</nowiki> will actually be replaced with whatever coding for the template is at <nowiki>[[Template:Something]]</nowiki>. If you edit the page again after saving, you will no longer see <nowiki>{{subst:something}}</nowiki> in the text.
+
However, if you ''substitute'' a template, the text <code><nowiki>{{subst:something}}</nowiki></code> will be replaced with the full template code from Template:Something when you save the page. If you edit the page again, you will no longer see <code><nowiki>{{subst:something}}</nowiki></code> in the text:
   
  +
[[File:Subst template.png|thumb|500px|center|The same template after being substituted.]]
==Why would I want to substitute instead of using a template directly?==
 
One reason is for things like welcome templates. Substituting these can be a good idea because welcome templates may change over time, and it can be odd to have someone's talk page change long after they have seen the notice. In addition, substituting it can give a better impression, as actual code can look more "human" than text saying <nowiki>{{welcome}}</nowiki>.
 
   
 
== Reasons for substituting ==
==See also==
 
  +
Most templates should not be substituted in pages, as doing so will make their contents harder to edit once added to a page. However, there are some instances where it can be useful.
*Learn more about [[Help:Templates|templates]]
 
*Learn more about [[Help:Editing|editing]]
 
   
  +
In some cases, templates that exist solely to provide formatting or quick links should be substituted rather than included normally. For example, if a template exists to create the full format link to a game page, as a shorthand for editors to type, it is better to substitute the template. Adding templates for small uses such as links can unnecessarily add to the max template count of a page for a minor function that can be replicated in wikitext.
==Further Help & Feedback==
 
  +
* Check [[Help:Getting help on Wikia]] for sources of further help
 
  +
In other cases, it may be that a template code is designed to be edited manually after it has been placed on a page. In these cases, substituting the template code, and immediately editing the page after, is ideal.
* Check [[Help:Contacting Wikia]] for how to report any errors or unclear steps in this article
 
  +
  +
For talk page messages, preserving the code of the template used at the time is often best, as it can be odd to have someone's talk page change long after they have seen the notice. This includes [[Help:Welcome tool|welcome templates]], as well as [[Help:Signatures|signatures]].
  +
  +
Additionally, it is possible to use template substituting to remove a template from pages. Simply clear out the contents of the template on the template page, and substitute it on all pages that included it, to remove it and any of its content.
  +
 
==See also==
 
*[[Help:Templates]]
 
*[[Help:Editing]]
   
 
==Further help and feedback==
__NOTOC__
 
  +
{{Help and feedback section}}
  +
[[ca:Ajuda:Substituint plantilles]]
  +
[[de:Hilfe:Vorlagen/Wikitext/Substitution]]
 
[[es:Ayuda:Sustituyendo plantillas]]
 
[[es:Ayuda:Sustituyendo plantillas]]
  +
[[fr:Aide:Substitution de modèles]]
  +
[[it:Aiuto:Sostituzione di template]]
  +
[[ja:ヘルプ:テンプレートの置換]]
  +
[[pl:Pomoc:Substytucja szablonów]]
  +
[[pt:Ajuda:Substituindo predefinições]]
  +
[[tr:Yardım:Şablonları yerine alma]]
  +
[[uk:Довідка:Вставка контенту з шаблонів]]
  +
[[vi:Trợ giúp:Thay thế bản mẫu]]
  +
[[zh:Help:替換引用模板]]
  +
[[Category:Editing]]
  +
[[Category:Source editing]]
 
[[Category:Help|Substituting templates]]
 
[[Category:Help|Substituting templates]]
[[Category:Expand|Substituting templates]]
+
[[Category:Tables & templates|{{PAGENAME}}]]

Revision as of 07:08, 1 December 2019

Template substitution is an alternate way to embed information contained in a template. Substitution is performed by placing the code subst: between the template braces, before the template name, like this:

{{subst:Templatename}}

Process

Normally, when the code for a template named {{something}} is added to a page, it will still say {{something}} in the wikitext when you next edit the page.

Non subst template

A template in the editor that has not been substituted.

However, if you substitute a template, the text {{subst:something}} will be replaced with the full template code from Template:Something when you save the page. If you edit the page again, you will no longer see {{subst:something}} in the text:

Subst template

The same template after being substituted.

Reasons for substituting

Most templates should not be substituted in pages, as doing so will make their contents harder to edit once added to a page. However, there are some instances where it can be useful.

In some cases, templates that exist solely to provide formatting or quick links should be substituted rather than included normally. For example, if a template exists to create the full format link to a game page, as a shorthand for editors to type, it is better to substitute the template. Adding templates for small uses such as links can unnecessarily add to the max template count of a page for a minor function that can be replicated in wikitext.

In other cases, it may be that a template code is designed to be edited manually after it has been placed on a page. In these cases, substituting the template code, and immediately editing the page after, is ideal.

For talk page messages, preserving the code of the template used at the time is often best, as it can be odd to have someone's talk page change long after they have seen the notice. This includes welcome templates, as well as signatures.

Additionally, it is possible to use template substituting to remove a template from pages. Simply clear out the contents of the template on the template page, and substitute it on all pages that included it, to remove it and any of its content.

See also

Further help and feedback