Jump to content
Main menu
Main menu
move to sidebar
hide
Content
Game Mechanics
Game Mechanics Main
Player Handout
Characters
Character Advancement
Attributes and Skills
Rules
Combat and Injuries
Movement and Chases
Space Travel
Combat
Character Sheets
Links
Aliens
Aliens Main
Races
Creatures
The Force
The Force Main
Force Powers
Lightsaber Fighting Styles
Force Paths
Force Weapons
Artifacts
Lightsaber Construction
Droids
Droids Main
1st Degree Droids
2nd Degree Droids
3rd Degree Droids
4th Degree Droids
5th Degree Droids
Droid add-ons and Junk
Starships
Starships Main
Starfighters
Space Transports
Capital Ships
Space Stations
Tactical Space Weapons
Starship Modifications
Equipment
Individual Ships
Star Systems
Star Systems Main
Deep Core
Core Worlds
Colonies
Inner Rim
Expansion Region
Mid Rim
Outer Rim
Wild Space
Hutt Space
Corporate Sector
Unknown Region
Vehicles
Vehicles Main
Airships
Airspeeders
Beast Vehicles
Gliders
Ground Vehicles
Hover Vehicles
Landspeeders
Rotor Vehicles
Sail Barges
Skiffs
Speeder Bikes
Swoops
Walkers
Watercraft
Equipment
Equipment Main
Structures and Bases
Communications
Conveyances
Droid add-ons and Junk
Information
Medical
Protective Equipment
Security
Surveillance
Survival
Tools
Weapons
Weapons Main
Artillery
Blasters
Grenades & Explosives
Melee Weapons
Miscellaneous Weapons
Missile Weapons
Poisons
Ranged Weapons
Thrown Weapons
Weapons Accessories
Characters
Characters Main
Templates
Non-Player Characters
Stock Non-Player Characters
Story Lines
Story Lines Main
Conrad Deception
After the Fall
Collapsible World
Retrieval
Crossovers
Crossovers Main
Alien vs Predator
Andromeda
Babylon 5
Battlestar Galactica
Farscape
Halo
Mass Effect
Mobile Suit Gundam
Perry Rhodan
Robotech Defence Force
Serenity
Shadowrun
Space Balls
Star Control
Stargate
Starship Troopers
Star Trek
The Last Starfighter
Warhammer 40,000
Wing Commander
Home Brewed
Home Brewed Main
Aliens
Equipment
Starships
Quests
Star Systems
House Rules
Navigation
Main page
Community portal
Current events
Recent changes
Random page
Help
Episode D6: Star Wars D6 Wiki
Search
Search
Appearance
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Help:Templates
(section)
Help page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Parameters== To enrich the mechanism of transclusion, MediaWiki allows parameters to be passed to a template when it is transcluded. Parameters allow the template to produce different contents or have different behaviors. Suppose you wish to insert a little thank you note in the [[Help:Talk pages|talk page]] of other users, such as: {{Thankyou|all your effort|Me}} 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. 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: <pre><nowiki>'''A little thank you...''' for {{{1}}}. hugs, {{{2}}}</nowiki></pre> Notice the use of <code><nowiki>{{{1}}}</nowiki></code> and <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: <code><nowiki>{{{ }}}</nowiki></code>. This is different from normal template name usage. When using the template on a page, you fill in the parameter values, separated by a pipe char (<code>|</code>). MediaWiki allows parameters to be passed to the template in three ways. === Anonymous parameters === To pass in anonymous parameters, list the values of those parameters sequentially: <nowiki>{{Thankyou|all your effort|Me}}</nowiki> In this case, template <code><nowiki>{{Thankyou}}</nowiki></code> receives parameters <code><nowiki>{{{1}}}=all your effort</nowiki></code> and <code><nowiki>{{{2}}}=Me</nowiki></code> and produces: {{Thankyou|all your effort|Me}} Inverting the order of the parameters: <nowiki>{{Thankyou|Me|all your effort}}</nowiki> causes template <code><nowiki>{{Thankyou}}</nowiki></code> to receive parameters <code><nowiki>{{{1}}}=Me</nowiki></code> and <code><nowiki>{{{2}}}=all your effort</nowiki></code> and inverts the result: {{Thankyou|Me|all your effort}} So, the order in which anonymous parameters are passed in is crucial to its behaviour. === Numbered parameters === To pass in parameters by number, identify each parameter when passing it: <nowiki>{{Thankyou|2=Me|1=your friendship}}</nowiki> This time, template <code><nowiki>{{Thankyou}}</nowiki></code> receives parameters <code><nowiki>{{{1}}}=your friendship</nowiki></code> and <code><nowiki>{{{2}}}=Me</nowiki></code>, though they have been supplied in inverse order, and produces: {{Thankyou|2=Me|1=your friendship}} === Named parameters === The third way of passing parameters is by name, instead of numbers. In this case, the template contents would be changed to: <pre><nowiki>'''A little thank you...''' for {{{reason}}}. hugs, {{{signature}}}</nowiki></pre> Within the template, we use <code><nowiki>{{{reason}}}</nowiki></code> and <code><nowiki>{{{signature}}}</nowiki></code> to identify each parameter, instead of a number. To pass these parameters by name, identify each parameter when passing it: <nowiki>{{Thankyou|signature=Me|reason=being who you are}}</nowiki> In this case, template <code><nowiki>{{Thankyou}}</nowiki></code> receives parameters <code><nowiki>{{{reason}}}=being who you are</nowiki></code> and <code><nowiki>{{{signature}}}=Me</nowiki></code> and produces: {{Thankyou|signature=Me|reason=being who you are}} The advantage of using named parameters in your template, besides also being flexible in the order parameters can be passed, is that it makes the template code much easier to understand if there are many parameters. === Default values === If you transclude a template that expects parameters, but do not provide them, in this way: <nowiki>{{Thankyou}}</nowiki> in the numbered parameters example above you would get the following: {{Thankyou}} 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: <pre><nowiki>'''A little thank you...''' for {{{reason|everything}}}. hugs, {{{signature|Me}}}</nowiki></pre> 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: <!-- 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 --> {{Thankyou|reason=everything|signature=Me}} ===Control template inclusion=== By default, the whole content of a template will be processed and displayed both when the template page is being viewed directly and when the template is being included in another page. However, you can control template inclusion by the use of <code><nowiki><noinclude></nowiki></code> and <code><nowiki><includeonly></nowiki></code> tags. Anything between <code><nowiki><noinclude></nowiki></code> and <code><nowiki></noinclude></nowiki></code> will be processed and displayed only when the template's page is being viewed directly, and will not be processed and displayed when it is included in another page. The application of this is to do things to the template page that should not be similarly done to the pages where it is included: * [[Help:Categories|Categorising]] the template. * Placing in the template [[Help:Links#Interlanguage links|interlanguage links]] to similar templates in other languages. * Presenting explanatory text about how to use the template. Anything between <code><nowiki><includeonly></nowiki></code> and <code><nowiki></includeonly></nowiki></code> will be processed and displayed only when the page is being included, and will not be processed and displayed when the template page is being viewed directly. The application of this is to do things in the pages where the template is included that you do not want to be similarly done in the template page: * [[Help:Categories|Categorising]] only the pages where the template is included. Note that when you change the categories applied by a template in this fashion, the categorization of all the pages where that template is included may not be updated until some time later: this is handled by the {{mediawiki|Manual:Job queue|job queue}}. To force the re-categorisation of a particular page, open the page for edit and save it without changes. * Ensuring that the template's code is not executed when viewing the template page itself. Normally this is because it isn't receiving any parameters and its execution without parameters has an undesired aspect. Of course, everything outside <code><nowiki><noinclude></nowiki></code> and <code><nowiki><includeonly></nowiki></code> tags is processed and displayed both when the template page is being viewed directly and when the template is being included in another page. ===Organizing templates=== For templates to be effective, users need to find them, and find out how to use them. To find them, users can: # Click '''Special Pages > All Pages''' # In the '''Namespace''' list, choose '''Template''' and click '''Go'''. To give usage information, include an example like this one on the template page: <pre><nowiki> <noinclude> == Usage == Welcome users: {{Thankyou|reason=your reason|signature=your signature}} </noinclude> </nowiki></pre> Then, an editor can simply copy and paste the example to use the template.
Summary:
Please note that all contributions to Episode D6: Star Wars D6 Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Episode D6: Star Wars D6 Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Help:Templates
(section)
Add topic