Difference between revisions of "Applying a template to all pages of a given category"
From FollowTheScore
(New page: == How can one apply a template to all pages of a certain category? == Sometimes you want to create a list of articles where each entry in the list points to an adress which is constructe...) |
|||
Line 9: | Line 9: | ||
== Answer == | == Answer == | ||
− | To invoke a | + | To invoke a template called "My special article lister" for all pages which are members of category "Fictitious country" you would have to write the following |
+ | <nowiki><pre> | ||
<dpl> | <dpl> | ||
category=Fictitious country | category=Fictitious country | ||
− | format=, | + | format=,{{My special article lister|%PAGE%}} |
+ | </dpl> | ||
+ | </pre></nowiki> | ||
+ | |||
+ | The result could like this: | ||
+ | <dpl> | ||
+ | category=Fictitious country | ||
+ | format=,{{My special article lister|%PAGE%}} | ||
</dpl> | </dpl> |
Revision as of 07:57, 29 August 2008
How can one apply a template to all pages of a certain category?
Sometimes you want to create a list of articles where each entry in the list points to an adress which is constructed from the article´s name. Basically, this means that you want to produce the equivalent of
{{some template|1st page in category}}
{{some template|2nd page in category}}
{{some template|3rd page in category}}
...
Answer
To invoke a template called "My special article lister" for all pages which are members of category "Fictitious country" you would have to write the following
<pre> <dpl> category=Fictitious country format=,{{My special article lister|%PAGE%}} </dpl> </pre>
The result could like this:
- This Italic textlist item refers to DPL Example 007 main page 1; it is constructed by Template:My special article lister
- This Italic textlist item refers to Nigunda; it is constructed by Template:My special article lister
- This Italic textlist item refers to Nigunda Test; it is constructed by Template:My special article lister
- This Italic textlist item refers to Somango; it is constructed by Template:My special article lister