Help:Dynamic Page List
Dynamic Page List allows editors to create a list of pages that are listed in a set of categories. A common need for a wiki page is to build a list of people, places, or things. Several approaches are used to accomplish this task including:
- Building a table (see help:table)
- Adding pages to a category and then going to that category to see the list. For example, see all of the pages in Category:Lists.
- Using a new extension called "Dynamic Page List" that allows you to build lists at any time with a high degree of flexibility (See below for more information).
Users are encouraged to consider using this dynamic page list tool as a way to organize your pages.
Use
DynamicPageList can be used with XML-like syntax in the wiki edit view. The parameters control the pages to list, order, and display mode. See the following sections for information on each parameter.
It is recommended that you use enhanced editor to initially set it up. Once saved, you can use VisualEditor to make edits. A separate window opens when you double click or single click and
<DynamicPageList> category = Pages recently transferred from Meta count = 5 order = ascending addfirstcategorydate = true </DynamicPageList>
An example of a really complex DynamicPageList:
<DynamicPageList> category=foo count=20 namespace=file addfirstcategorydate=ymd imagewidth=70 galleryshowfilesize=yes galleryshowfilename=yes imagesperrow=7 gallerycaption=Galleries! ordermethod=sortkey order=ascending mode=gallery offset=12 </DynamicPageList>
Lists the 12th to the 34th pages in the file namespace that are also in category foo, formatting them into an image gallery, with the date they were added to category foo in the caption in year month day format, and having the images have a width of 70px
Page selection
category
category lists categories to intersect. DynamicPageList will list pages that are found in every category listed. A minimum and maximum number of entries to list is set in the extension's source code. You may use magic words like {{CURRENTMONTHNAME}} in the category name.
The syntax is category = category name
<DynamicPageList> category = Demo category = Demo 1 </DynamicPageList>
notcategory
notcategory restricts the list of pages to those not in a particular category. You can use magic words like {{CURRENTMONTHNAME}} in the category name.
<DynamicPageList> category = Demo notcategory = Demo 1 </DynamicPageList>
namespace
namespace restricts the list of pages specified above to those in a particular namespace, specified by name or number (see the List of default namespaces). Any invalid name is equivalent to the main article namespace.
<DynamicPageList> category = Demo namespace = Help </DynamicPageList>
redirects
redirects determines whether or not to include redirect pages. The value can be exclude (default, don't list redirects), include (list redirects), or only (don't list pages that aren't redirects).
<DynamicPageList> category = Demo redirects = only </DynamicPageList>
count
count restricts the number of results that are shown. By default, the pages added to the category most recently are shown (see order). Note that the extension will not list more results than the maximum defined in the extension source code.
<DynamicPageList> category = Demo count = 2 </DynamicPageList>
offset
offset starts the list from somewhere other than the first page on the list. For example, this can be used with count to make multi-column layouts.
<DynamicPageList> category = Demo offset = 2 </DynamicPageList>
Column demo
<table> <tr><th colspan="3"> recent articles in [[:category:Demo]]</th></tr> <tr><td> <DynamicPageList> category = Demo count=5 </DynamicPageList> </td> <td> <DynamicPageList> category = Demo offset = 5 count= 5 </DynamicPageList> </td> <td> <DynamicPageList> category = Demo offset = 10 count=5 </DynamicPageList> </td></tr></table>
Details displayed
shownamespace
shownamespace displays the namespace in the page names. The value can be true (default, display in name: Help:Contents) or false (don't display in name: Contents).
<DynamicPageList> category = Demo shownamespace = false </DynamicPageList>
addfirstcategorydate
addfirstcategorydate shows the date each article was added to category. The value can be true (display date), false (default, don't display date), or a date specifier (ymd, md, dm, dmy, mdy, and ISO 8601). If many categories are specified, it uses the first category. The linked page names are prepended with the date formatted according to your local MediaWiki date display preferences.
<DynamicPageList> category = Demo addfirstcategorydate = true </DynamicPageList>
mode
mode determines the format of the list. The value can be:
- unordered — bulleted list
- ordered — numbered list
- none — plain links with line breaks
- gallery — image gallery, like <gallery>
- inline — comma separated list
unordered: <DynamicPageList> category = Demo mode = unordered </DynamicPageList> ordered: <DynamicPageList> category = Demo mode = ordered </DynamicPageList> plain links: <DynamicPageList> category = Demo mode = none </DynamicPageList> inline: <DynamicPageList> category = Demo mode = inline </DynamicPageList>
mode=gallery
Gallery is a special mode where the output is an image gallery. When using this mode, you would usually want to restrict the namespace to file.
<DynamicPageList> category = Demo mode = gallery namespace= file </DynamicPageList>
Gallery mode also supports the options imagewidth (how wide the images should be in gallery, you may need to also set imageheight if using this), imageheight (how high the image should be) galleryshowfilesize (show the image size, like on category pages), galleryshowfilename (show filename like on category pages), imagesperrow (number of images per row in gallery), gallerycaption (caption for gallery).
If addfirstcategorydate is in use, the date is appended to the caption of the image.
Note, gallerycaption at the moment cannot accept links. (but it can accept things like {{CURRENTMONTHNAME}})
A complex gallery example might be:
<DynamicPageList> count=20 namespace=file addfirstcategorydate=ymd imagewidth=70 galleryshowfilesize=yes galleryshowfilename=yes imagesperrow=7 gallerycaption=Look at my pretty gallery. mode=gallery </DynamicPageList>
suppresserrors
suppresserrors hides errors. The value can be true (hide errors) or false (default, show errors).
true: <DynamicPageList> category = Dem suppresserrors = true </DynamicPageList> false: <DynamicPageList> category = Dem suppresserrors = false </DynamicPageList>
nofollow
nofollow sets rel="nofollow" on the links. This prevents spiders from getting to the page through the link from the DynamicPageList. In general this is useless, as spiders will either be able to index the page from other links, or not at all due to robots.txt/$wgDefaultRobotPolicy. In general you should not use this option unless you know what you are doing, and have a good reason. The primary usecase is that on the English Wikinews, Google News considers anything linked from the main page to be an article.
<DynamicPageList> category = Demo nofollow = true </DynamicPageList>
googlehack
This is a hack for wikinews. Previously, Google News only considered articles with numbers in them to be news articles [1], so this appends ?dpl_id=<id of article> to the end of the urls on the list. You shouldn't use this option unless you have a good reason to (however it won't hurt anything). This replaces the showcurid option that is no longer supported.
<DynamicPageList> category = Demo googlehack = true </DynamicPageList>
Order
ordermethod
ordermethod determines the order and date to display. The value can be:
- categoryadd — default, sort by date pages were categorised for first category
- lastedit — sort by date pages were last edited
- length — by article length
- created — by article creation date
- categorysortkey — essentially alphabetical order by the sort key of the first category
- sortkey — alias of categorysortkey
- popularity — by number of hits
It should be noted, that lastedit really sorts by the last time the page was touched. In some cases this is not equivalent to the last edit (for example, this includes permission changes, creation or deletion of linked pages, and alteration of contained templates). popularity is only enabled on wikis that have $wgDisableCounters set to false. As such it will not work on Wikimedia wikis. If you do not specify a category, some of these order methods will not work—specifically, categoryadd and categorysortkey fallback to created if there is no category clause.
<DynamicPageList> category = Demo addfirstcategorydate = true ordermethod = lastedit </DynamicPageList>
alphabetical example:
<DynamicPageList> category = Demo ordermethod = sortkey </DynamicPageList>
order
order decides the sort direction. The value can be descending (default, most recent to oldest) or ascending (oldest to most recent).
<DynamicPageList> category = Demo order = ascending </DynamicPageList>
Templates
To use inside a template and pass parameters, use parser functions etc., use the {{#tag: function:
{{#tag:DynamicPageList|
category = {{{1}}}
count = {{#if: {{{2|}}} | 10 | 20 }}
ordermethod = sortkey
order = ascending
}}
The template page itself will display an error message because the category value is empty on the template page unless you put the template inside <includeonly> tags. Example:
Error: You need to include at least one category, or specify a namespace!
How to use this capability
DynamicPageList can be used with XML-like syntax in the wiki edit view. The parameters control the pages to list, order, and display mode. See the following sections for information on each parameter. The most complete instruction set for the DPL capability can be see at Extension:DynamicPageList (Wikimedia)
.
Output
Use suppresserrors=true to suppress error messages for an empty DPL, e.g. if the selected category Saintssn't exist.
The default output mode=unordered presents the DPL as unordered list, XHTML <ul>, like Wiki list markup *.
Similarly ordered results in numbered <ol> output like Wiki list markup #. Finally mode=none presents
the DPL with one entry per line, terminated with <br />, roughly similar to Wiki list markup ; (semicolon).
Especially in conjunction with namespace= the attribute shownamespace=false allows to suppress the output of the namespace.
Sorting
DPLs are either sorted by the date of the addition to the first category (this is often not the date of the creation of the
individual page).
- ordermethod=categoryadd (Default)
- ordermethod=lastedit - the date of the last modification of the member pages
- created
Sorting can be order=descending (default, most recent first) or order=ascending, allowing to look at the same set from both
ends in two DPLs (see above).
Dates
With addfirstcategorydate=true the date of the addition to the first category is shown.
Parameters
If you want to use DPL within a template and send in parameters, use the following format as an example. This particular example would be used within a template and would have two parameters being sent in. To learn more about tools like the #if statement, see Parser functions.
{{#tag:DynamicPageList|
category = {{{1}}}
count = {{#if: {{{2|}}} | 10 | 20 }}
ordermethod = sortkey
order = ascending
}}
Other options
- namespace= - Allows you to filter the results by namespace.
- shownamespace=
- true - Shows the namespace before the article title, such as User:Afbrouwer.
- false - Hide the namespace before the article title. User:Afbrouwer is listed as Afbrouwer.
- suppresserrors=
- true - If no pages match the criteria, it will not show anything in the space.
- false - If no pages match the criteria, it will show "Error: No results!" This is the default option.
Examples
List Acts of Congress in ascending order
<DynamicPageList> category=Acts of Congress ordermethod=sortkey order=ascending </DynamicPageList>
List Acts of Congress in ascending order only in Main namespace
<DynamicPageList> category=Acts of Congress ordermethod=sortkey order=ascending namespace=0 </DynamicPageList>
Display in column format
'''The 15 most recent articles added to [[:Category:Saints]]'''
{{div col | colwidth=300px}}
<DynamicPageList>
category = Saints
count=15
</DynamicPageList>
{{div col end}}
The 15 most recent articles added to Category:Saints
List pages that are assigned to BTP Regulatory Actions but not those about appliances
<DynamicPageList> category=BTP Regulatory Actions notcategory=Appliances Regulatory Actions ordermethod=sortkey order=ascending </DynamicPageList>
History
The Dynamic Page List extension is a tool that allows filtering of pages and content by a variety of parameters including categories. It is a powerful scripting tool that works within MediaWiki. The curators of Saintapedia were interested enabling this extension with Saintapedia and Private wikis so as to enable tracking of actions and building complex lists from various categories.
More information and help
- https://dpl3.wikitide.org/wiki/Criteria_for_page_selection
- help page on Metawiki
- Dynamic Page List extension on MediaWiki server.
- GoogleNewsSitemap derivative extension, which might be the better option as it allows outputing of RSS an Atom feeds. Need evaluation.
- DPLdemo wiki has examples:
- example dynamic filter using DPL
- overview page with details on how DPL works
- main of the wiki