Difference between revisions of "DPL Example 007"

From FollowTheScore
Jump to: navigation, search
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
__NOTOC__
 
{{Example|Show members of a category and of all its subcategories}}
 
{{Example|Show members of a category and of all its subcategories}}
  
We use two nested DPL statements.
+
Ideally we would like to use a template which calls itself recursively. But MediaWiki tries to be clever and blocks such calls. So we have to use a separate template for each level. So, if you need more than two levels you must ''copy the source code'' of [[Template:DPL Example 007 sub 2]] to ''Template:DPL Example 007 sub 3'' etc. 
 +
 
 +
You could redirect your (super-)category page to a page which contains the DPL call shown below. The readers would then automatically always see all pages belonging to subcategories. You should probably change the name ''´Template:DPL Example 007 sub'' to something like ''Template:Traverse category''. Adapt the output format to your needs - our example uses bullets and three columns.
  
 
<pre><nowiki>
 
<pre><nowiki>
 +
{{DPL Example 007 sub|DPL Example 007 main cat}}
 
</nowiki></pre>
 
</nowiki></pre>
  
Line 10: Line 14:
 
----
 
----
  
{{#dpl:
+
{{DPL Example 007 sub|DPL Example 007 main cat}}
|category=Example 007 main cat
 
|notnamespace=Category
 
}}
 
{{#dpl:
 
|category=Example 007 main cat
 
|namespace=Category
 
|format=,²{DPL Example 007 sub¦%PAGE%}²,\n,
 
}}
 

Latest revision as of 00:16, 10 March 2009

back to list of examples

Show members of a category and of all its subcategories

Ideally we would like to use a template which calls itself recursively. But MediaWiki tries to be clever and blocks such calls. So we have to use a separate template for each level. So, if you need more than two levels you must copy the source code of Template:DPL Example 007 sub 2 to Template:DPL Example 007 sub 3 etc.

You could redirect your (super-)category page to a page which contains the DPL call shown below. The readers would then automatically always see all pages belonging to subcategories. You should probably change the name ´Template:DPL Example 007 sub to something like Template:Traverse category. Adapt the output format to your needs - our example uses bullets and three columns.

{{DPL Example 007 sub|DPL Example 007 main cat}}

The above DPL command produces the following output:


Pages in category     DPL Example 007 main cat

    Pages in subcategory     DPL Example 007 sub cat 1

      Pages in subcategory     DPL Example 007 sub cat 2