Difference between revisions of "DPL Example 018"

From FollowTheScore
Jump to: navigation, search
(New page: {{subst::DPL Example 017}})
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Create a permuted index of template calls ==
+
__NOTOC__
 +
{{Example|List of relations, templates, categories and images for a given page}}
  
Sometimes you want to know, which pages use a certain template with a special value.
+
We show all kinds of references to other wiki objects. This list could be enhanced to be used in Special:Export to download an article together with its context. Maybe it could be enhanced to create a "transitive envelope of variable depth", i.e. the procedure could be repeated for all neighbours to create a list of "leven n-neighbours".
If you know the value you are interested in, you can use <tt>includematch</tt>.
 
  
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.
+
<pre><nowiki>
 +
{{DPL Example 018 sub|DPL Example 010 page 1}}
 +
</nowiki></pre>
  
In our example we have created two pages which use a template called [[Template:Index|Index]] with one or more parameters:
+
----
{{#dpl:
+
The above DPL command produces the following output:
|uses=Template:Index
+
----
|include={Index}.dpl1
 
}}
 
  
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://mediawiki.org/Extension:Array array] which is sorted and printed afterwards.
+
wiki objects in distance 1 from [[DPL Example 010 page 1]] :
The result looks like this:
+
 
{{#arraydefine:inx|
+
<tt>
  {{#replace:
+
{{DPL Example 018 sub|DPL Example 010 page 1}}
    {{#dpl:
+
</tt>
      |uses=Template:Index
 
      |include={Index}.dpl2
 
      |format=,,;
 
    }}
 
    |/;$/
 
    |
 
  }}
 
|;}}
 
<!-- now we have an array where each element has two parts which are separated by °;
 
    the first part is the parameter value, the second part is the name of the referring wiki page
 
    we sort the array and then print an indented list where common first elements are shown only once
 
-->{{#arraysort:inx|asce}}<!--
 
-->{{#arrayprint:inx|<br/>|%%|{{#vardefine:src|{{#replace:%%|/°.*/|}}}} {{#ifeq:{{#var:src}}|{{#var:srcold}}||'''{{#var:src}}'''<br/>}}{{#replace:[[%%]]|/^(\[\[){{#var:src}}°/|&nbsp; &nbsp; &nbsp;\1}}{{#vardefine:srcold|{{#var:src}}}}}}
 

Latest revision as of 08:21, 24 May 2009

back to list of examples

List of relations, templates, categories and images for a given page

We show all kinds of references to other wiki objects. This list could be enhanced to be used in Special:Export to download an article together with its context. Maybe it could be enhanced to create a "transitive envelope of variable depth", i.e. the procedure could be repeated for all neighbours to create a list of "leven n-neighbours".

{{DPL Example 018 sub|DPL Example 010 page 1}}

The above DPL command produces the following output:


wiki objects in distance 1 from DPL Example 010 page 1 :

DPL example page 2
DPL example page 3
Template:DPL Example 010 tpl
{{#replace:Category:DPL Example 010 cat, DPL Example 010 cat2|,|
Category:}}
File:Sudan n3.jpg