Difference between revisions of "Template:Invocations"

From QBWiki
Jump to navigation Jump to search
m
Line 3: Line 3:
 
A simple counter that can be used to track the number of times a particular template has been invoked ''if'' included exactly once. Emits a value that will be consistent for a given invocation, meaning it can be used to define invocation-specific variables.
 
A simple counter that can be used to track the number of times a particular template has been invoked ''if'' included exactly once. Emits a value that will be consistent for a given invocation, meaning it can be used to define invocation-specific variables.
  
This '''only works when substituted'''.
+
This '''does not work as intended''' because of how "<nowiki>{{FULLPAGENAME}}</nowiki>" always takes the name of the outermost page, not any intermediate templates. To achieve the desired behavior, manually define a variable and iterate it.
  
 
<pre>
 
<pre>

Revision as of 18:02, 20 December 2025

Template documentation

A simple counter that can be used to track the number of times a particular template has been invoked if included exactly once. Emits a value that will be consistent for a given invocation, meaning it can be used to define invocation-specific variables.

This does not work as intended because of how "{{FULLPAGENAME}}" always takes the name of the outermost page, not any intermediate templates. To achieve the desired behavior, manually define a variable and iterate it.

{{Invocations}} -> {{Invocations}} -> {{Invocations}} ({{#var:Template:Invocations_invocations}}, {{#var:invocations}})

{{Invocations/test}} -> {{Invocations/test}}

1 -> 2 (, 2)