Difference between revisions of "Test numberOfArticles"
From FollowTheScore
(→Another way to show multiple article counts) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{Type | + | {{Type Test |
|parameter = resultsheader and number of pages | |parameter = resultsheader and number of pages | ||
}} | }} | ||
Line 5: | Line 5: | ||
==Show the number of articles in a certain category== | ==Show the number of articles in a certain category== | ||
− | This test shows how to put a DPL statement into a [[Template:DPL Count|template]] (just for fun in this case) | + | This test shows how to put a DPL statement into a [[Template:DPL Count|template]] (just for fun in this case) and how to return the number of articles instead of their names. We are going to use the <tt>[[resultsheader]]</tt> parameter which allows you to use a variable called <tt>[[%PAGES%]]</tt>. |
− | and how to return the number of articles instead of their names. We are going to use | + | |
− | the | + | Use a template which contains this code: |
<pre><nowiki> | <pre><nowiki> | ||
− | |||
{{#dpl: | {{#dpl: | ||
|category = {{{category}}} | |category = {{{category}}} | ||
+ | |resultsheader = There are %PAGES% articles on [[:Category:{{{category}}}{{!}}{{{category}}}]] in this wiki. | ||
+ | |noresultsheader = This wiki doesn´t contain any articles on ''{{{category}}}''. | ||
|mode = userformat | |mode = userformat | ||
− | |||
− | |||
}} | }} | ||
+ | </nowiki></pre> | ||
− | + | {| | |
− | + | |- valign=top | |
− | </nowiki></pre> | + | | Call the template: |
+ | <pre><nowiki>{{DPL Count|category=Fictitious Country}}</nowiki></pre> | ||
+ | |||
+ | | Result: | ||
− | + | {{DPL Count|category=Fictitious country}} | |
− | + | |} | |
==Another way to show multiple article counts== | ==Another way to show multiple article counts== |
Latest revision as of 11:32, 28 January 2008
Test | resultsheader and number of pages |
Show the number of articles in a certain category
This test shows how to put a DPL statement into a template (just for fun in this case) and how to return the number of articles instead of their names. We are going to use the resultsheader parameter which allows you to use a variable called %PAGES%.
Use a template which contains this code:
{{#dpl: |category = {{{category}}} |resultsheader = There are %PAGES% articles on [[:Category:{{{category}}}{{!}}{{{category}}}]] in this wiki. |noresultsheader = This wiki doesn´t contain any articles on ''{{{category}}}''. |mode = userformat }}
Call the template:
{{DPL Count|category=Fictitious Country}} |
Result:
There are 4 articles on Fictitious country in this wiki. |
Another way to show multiple article counts
This time we use the headingmode and headingcount parameters. Note that we get a message for each category (except Villages as there are no articles in that category) .
<dpl> ordermethod=category,lastedit category=+Fictitious country|Countries|Cities|Villages headingmode=H4 headingcount=true mode=userformat </dpl>
Extension:DynamicPageList (DPL), version 3.2.1: Warning: Skipping bad option 'H4' for parameter 'headingmode'.
Extension:DynamicPageList (DPL), version 3.2.1: Warning: No results.