Help

Wiki Glossary

From Dogcraft Wiki

Revision as of 01:52, 19 February 2023 by Domino (talk | contribs)

Templates

Templates work by including the content of one page inside the content of another, this is called "transclusion". Here B is the template, and it is being using on A, X and Y.

Templates are a consistent way to re-use text (or other content) across the wiki, regardless of what page your editing. Every template has a name, some content, and may have parameters. A template's name is always the name of a wiki page in the Template: namespace.

When you add a template to a page, you only need to add its name (and any parameters), and when viewing said page, the template name will be replaced with whatever is on the Template: page the name is pointing to. When editing the page, you will continue to see the template behave differently from the rest of the page.

  • In the VisualEditor, you can add templates using their own popup menu, in the top-bar at Insert > Templates by searching for the template's name.
  • In the Source Editor, you can add a template using a popup menu (accessed from the top-bar with the template-wizard-button button), or by surrounding the template's name with two brackets like this: {{template name}}.

For example, lets look at the "Egg" template.

  • Here, the name of the template is Egg, and it doesn't have any parameters.
  • If you look at the Template:Egg page, you'll see the text "Eggs are great for breakfast.", that's the template's content.

Adding the template on any page will show that sentence once you exit the editor. So, {{Egg}} generates: "Eggs are great for breakfast.". And if you were to change the text on the Template:Egg page to "Omelettes are great for breakfast.", then everywhere the Egg template is used would update automatically!

Parameters

The contents of a template (whatever is on the Template:Template name page) can have special sections of text called a parameter. Parameters are kind of like variables or inputs, they can be specified on the page that's using the template. They usually have their own names and values.

  • In the VisualEditor the template popup menu has a textbox for every parameter.
  • In the Source Editor, the popup menu can be used, or parameters can be added like this: {{template name|parameter_name = value|another_parameter_name = value}}.

For example, lets look at the Read more template:

  • Here, the name of the template is "Read more"
  • It has 1 parameter called "name"
  • The content is "To read more about the topic, see the {{{name}}} page."

If you wanted to use this template on a page, you could do {{Read more | name = Leon}} to generate "To read more about the topic, see the Leon page."

Creating parameters: If you are making a template, inside a its content, it can refer to a parameter by its name, which when its added to a page will be replaced by its specified value. A template's content is always edited using the Source Editor. In there, parameters are marked by their name being surrounded with 3 brackets. (Eg.: {{{parameter name}}})

Useful tools

WhatLinksHere

Special:WhatLinksHere/<pagename> lists every single page which has a link to <pagename>. Template transclusions also count as a 'link', so you can get a list of all pages where a specific template is in use. Every page has a button in the bottom right red box pointing to its Special:WhatLinksHere page, so you can get here fast. (This can be useful for redirects too, which are also included as 'links'.)

uselang=qqx

When working with system messages, you can add ?uselang=qqx to the end of the page URL (or &uselang=qqx if the URL already has a question mark), which will show all the messages in use on the page by their name instead of their content. This can be extremely useful to find what message to edit! Image

This page was last modified on 19 February 2023, at 01:52. (3 months ago)
Background Takeshi by Edo