Jump to content

User:Pi zero/Archives/on this day/p4/doc

From Wikinews, the free news source you can write!

Usage

[edit]

This is the final subtemplate of {{User:Pi zero/Archives/on this day}}. It takes as its single parameter a year. If the category for today in that year is empty, it returns empty output; if the category is not empty, it outputs the year and a single randomly selected article from this day in that year. The random select is achieved by a DPL for the date category, restricted to published articles (mainspace, Category:Published, etc.), of length 1, with a randomly generated offset.

Properly speaking, this ought to depend not on the number of pages in the category, but on the number of published articles in the category; but the wiki software, including the DPL extension, does not provide any way for a template to access this information. As of this writing, the range of the random offset is deliberately one less than the number of pages in the category, to allow for the possibility there might be one unpublished page in the category. If there are no unpublished pages for the date, and more than one published article, then one of the published articles will never be randomly selected. If there is more than one unpublished page in the category, this subtemplate may randomly produce the year heading with nothing under it; and if there is at least one unpublished page in the category but no published ones, it will always do this.