Template:Format featured image.index/doc

This page documents both the Template:Featured image/index function and its phantom template Template:Format featured image.index.

Featured image/index
The featured image index is a handy sortable table of all the images that have been used in the set of featured image files (see the links on Template:Featured image/doc). It is generated by the following DPL function:

Format featured image.index
This template is what's called a surrogate template or a phantom template in DPL parlance. The Featured image/index function calls this template every time it finds an instance of Format featured image in its searching. This template is called with the same parameters as the template invocations that it finds, i.e., the image, caption, and usethis parameters from each featured image page. Two additional parameters are passed to this template, named %PAGE% and %TITLE%, which evaluate to the full page name and the page title respectively.

Here is the important part of the template:


 * 75px]]
 * 75px]]



As you can see, it uses a lot. This is a string parser function that breaks a string at a given delimiter and returns one of the pieces specified by a position number. First piece is number zero, next is one, and so on. See the documentation on string functions for more detail.

By the time this template is called, a wikitable has already been started, and all we have to do is return a row of data. Actually, the first column (a link to the featured image file) has already been generated by the index function, so we are returning columns 2 through 5 (Image Name, Thumbnail, When, and DOY).
 * Image Name : the value of image should be something like, so first we explode it using the pipe (" &#124; ") as the delimiter, but since pipe is also used to separate parameters in parser functions, we have to use the | template to insert the pipe character in the spot we need it. We choose the first piece (piece 0), which looks like  , and we explode that using the colon (" : ") as the delimiter. Choosing the second piece (piece 1) of that gives just the image file name.
 * Thumbnail : Same explode used above gives  to which we tack on   to make a small thumbnail version of the image.
 * When : We present the value of the usethis parameter in upper case, just because.
 * DOY : The %TITLE% parameter evaluates to the name of the file found by the calling template, not including the namespace,  for example. We explode this at the forward slash (" / ") and take the second piece which in the example would be  . We give this to the   function and it returns the Day Of Year (it assumes the current year).