Template:Template parameter value/doc: Difference between revisions

Content deleted Content added
Examples: Be specific about the checked template
Revamp of docs following major module update
Line 1:
{{Documentation subpage}}
{{Tmbox
| image = [[File:Information.svg|40px]]
| textstyle = color: black;
| text = '''''Warning'''''{{hair space}}: This template is buggy, and only works when pulling simple values, such as numbers and unformatted strings. Although the template makes some effort to handle piped links, most wikitext that includes pipes (e.g. values containing templates) cannot be pulled with this template.
}}
{{Shortcut|Template:Tmpv}}
{{Lua|Module:Template parameter value}}
Line 15 ⟶ 10:
This template works with named or numbered parameters; i.e. it can get the first parameter of {{tl|Start date}} (the year). This template is case-sensitive; i.e. setting {{para|Viewers}} will not match {{para|viewers}}. Make sure that you are listing the article where the template exists, not where it's transcluded to.
 
=== Basic Syntax ===
: <code><nowiki>{{Template parameter value|ARTICLE|TEMPLATE|TEMPLATE-COUNT|PARAMETER|PARAMETER-COUNT}}</nowiki></code>
 
Line 39 ⟶ 34:
: {{Template parameter value|The Big Bang Theory|Start date|8|3}}
 
=== ParametersModule usage ===
The module can be used directly for other modules through the function <code>getValue(page, templates, parameters, options)</code>, which will return a success boolean and either why it failed or the resulting parameter value.
{| class="wikitable"
 
! colspan="2" | Parameter
<code>page</code>, <code>templates</code>, and <code>parameters</code> are all required arguments. <code>options</code> is an optional table which can have the values <code>templateIndex</code>, <code>parameterIndex</code>, and <code>ignoreSubtemplates</code> (see the Template data for reference)
! Description
 
! Type
|== Template data ==
! style="width:15%" | Status
<templatedata>
|-
{
! style="width:4%" | 1
"params": {
| Article
"1": {
| The article where the template and value exist.<br />''Example:'' List of Lucifer episodes
"label": "Page",
| Text
"description": "The page to grab templates from",
| Required
"type": "wiki-page-name",
|-
"required": true
! 2
},
| Template
"2": {
| The template where the value is held in the form of a parameter.<br />''Example:'' Episode table
"label": "Templates",
| Text
"description": "The templates to look for in the target page. Can be provided in a comma split list to check for multiple templates",
| Required
"type": "string",
|-
"required": true
! 3
},
| Numbered usage of template
"3": {
| How many usages of the above template are counted.<br />Setting to blank sets the value to 1; do ''not'' exclude this parameter. Exclusion means that the third parameter will become the named/numbered parameter, which will cause the template to not work (return blank).<br />''Example:'' 24
"label": "Template index",
| Number
"description": "Which occurance of the template to check for parameters in",
| Optional setting<br />Required inclusion (see examples above)
"type": "number"
|-
},
! 4
"4": {
| "label": "Parameter",
| The named/numbered parameter in the template that holds the required value.<br />For a numbered parameter, for example, the 2nd numbered parameter will have an input of 2.<br />''Example:'' OriginalAirDate / 2
"description": "The name of the parameter to check for",
| Number / Text
"type": "string",
| Required
"required": true
|-
},
! 5
"5": {
| Numbered usage of parameter
"label": "Parameter index",
| How many usages of the above parameter are counted within the found template.<br />Setting to blank or excluding (exclusion allowed) sets the value to 1. Set to blank or 1 for a numbered parameter.<br />''Example:'' 3
"description": "Which occurance of the parameter to check for in the template. Does not apply if \"ignore_subtemplates\" is used",
| Number
"type": "number"
| Optional (see examples above)
| },
"ignore_subtemplates": {
"aliases": [
"ist"
],
"label": "Ignore subtemplates",
"description": "Ignores subtemplates and their parameters when looking for a value in a template. Can be used to increase the precision of the grabbing as opposed to using Parameter index",
"type": "boolean"
}
},
"description": "A template to grab the value of parameters from templates on other pages",
"format": "inline"
}</templatedata>
 
== See also ==
* {{tl|get parameter}}, another template doing the same thing with a different set of limitations