Difference between revisions of "DPL Example 017"
(2 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
}} | }} | ||
− | In our example the template ''Index'' does nothing; it could, however, tell the reader, that this page belongs to a | + | In our example the template ''Index'' does nothing; it could, however, tell the reader, that this page belongs to a certain index group - just like mediawiki lists the categories of a page at the bottom of your wiki browser. The surrogate template we use in the DPL query constructs an [http://www.mediawiki.org/wiki/Extension:ArrayExtension Array] which is sorted and printed afterwards. |
+ | The result looks like this: | ||
{{#arraydefine:inx| | {{#arraydefine:inx| | ||
{{#replace: | {{#replace: |
Latest revision as of 13:13, 24 May 2009
Create a permuted index of template calls
Sometimes you want to know, which pages use a certain template with a special value. If you know the value you are interested in, you can use includematch.
If you want a complete listing of all parameter values and the pages that are using them you can build a permuted index. (Note: The category system of MediaWiki is also a permuted index). If a page uses more than one value it will appear in the result more than once. If several pages use the same value they will be listed below that value.
In our example we have created two pages which use a template called Index with one or more parameters:
- Test inx Fruit 1 = apples 2 = walnuts
- Test inx Nuts 1 = almonds 2 = hazelnuts 3 = walnuts
In our example the template Index does nothing; it could, however, tell the reader, that this page belongs to a certain index group - just like mediawiki lists the categories of a page at the bottom of your wiki browser. The surrogate template we use in the DPL query constructs an Array which is sorted and printed afterwards. The result looks like this: {{#arraydefine:inx|
{{#replace: apples°Test inx Fruit
- walnuts°Test inx Fruit;almonds°Test inx Nuts
- hazelnuts°Test inx Nuts
- walnuts°Test inx Nuts;
|/;$/ | }}
|;}}
{{#arraysort:inx|asce}}{{#arrayprint:inx|
|%%|{{#vardefine:src|{{#replace:%%|/°.*/|}}}} {{#var:src}}
{{#replace:%%|/^(\[\[){{#var:src}}°/| \1}}{{#vardefine:srcold|{{#var:src}}}}}}