Category:Autoreferencing templates
Many pages refer to one or more related pages or files. For example, a File: page for a PNG bitmap might refer to an SVG vector version of the same image. Another example is a multilingual SVG file that needs a specific parameter to display a specific language. Although these page references can be explicitly entered, it can be more convenient and less error prone to generate these references automatically. For example, the PNG and SVG versions of an image may differ only in the extension (.png versus .svg). For a multilingual SVG file, the reference name stays the same, but the |lang=
argument changes.
The automatic generation of these references is often done within a template. Using a template hides the mechanics of substituting a different extension or building a reference with different arguments. These templates build an automatic reference by editing the name of the page where they are transcluded.
Automatic reference templates[edit]
Many templates have a |file=
parameter that identifies an image to display or reference. For example, {{Lang gallery}} is a template that displays a gallery of specific language versions of the referenced multilingual SVG file. Transcluding that template with {{Lang gallery|file=Conic Sections.svg|en|de|fr|ru|he|ja}}
produces:
A template transclusion with a fully specified file will work in most wiki namespaces
Defaulting a file parameter[edit]
Some templates will default the |file=
parameter to something sensible. For example, the {{Lang gallery}} template is most often used to show the available languages on that file's description page (File namespace). So on the File:Conic Sections.svg page, the |file=
parameter is optional. The {{Lang gallery}} notices that the |file=
parameter was not provided, so it defaults that parameter to the FULLPAGENAME (which would be File:Conic Sections.svg). The FULLPAGENAME for this category page is Category:Autoreferencing templates
.
When a template is transcluded, the FULLPAGENAME refers to invoking page and not the page name of the template.
The file defaulting can be slightly more inclusive. If the template concatenates the File
namespace with the BASEPAGENAME, then the default file will work in both the File
and File talk
namespaces because the BASEPAGENAME is the same for both pages. The BASEPAGENAME for this category page is Autoreferencing templates
.
These multilingual gallery templates use the |file=
defaulting strategy described above:
If the file is not specified, then the BASEPAGE is used. The file defaulting will work only if the BASEPAGE refers to a sensible file. For example, using one of these templates in the Commons
namespace requires an explicit |file=
because the BASEPAGENAME will not refer to an SVG image. In other namespaces, the file must be fully specified.
Not specifying is also an option for the template Vector version available, aka Vva: when transcluded from a raster image without file parameter, the SVG version with the same filename is shown. {{SimplSVG}} has a similar option.
Composing a file parameter[edit]
The opposite direction, from SVG to raster, can work e.g. when template {T0|Superseded}} is invoked from an SVG file; the name of the raster image can either be skipped (.png will be assumed), fully specified, or shortcut with only the extension.
Another series of templates may reference another file, but as well it can be used without any such link.
Reference to a file only differing by the extension is possible, it will be enough do specify only the extension:
- {{AutVec}} for mere vectorizations to show the raster image where an SVG file comes from
- {{Own based}} one or more files used as a base
- {{Vector version available}} will always link to an SVG file
- {{Other version}}
- {{Supersedes}}
- {{Derivative versions}}
- {{Derived from}}
- {{Filelist}}
- {{File}}
- {{F}}
- {{G}}
and more. For all these templates an extension as e.g. .pdf or .JPG, specified instead of a file name, will be completed with the name of the file from where the transclusion occurs; like any other part of the file name it is case-sensitive. For some standard extension forms exist abbreviations, as
.g
for .gif.j
for .jpg.p
for .png (also just.
is sufficient).t
for .tif.s
for .svg.x
for .xcf- and the more exotic extensions djvu, mid, ogg, webp with the
.
and their first letter.
This composing is triggered when the pseudo file name starts with a dot. If a real file name itself happens to start with a dot, prefixing it with a namespace like File:.Xyz.jpeg can avoid conflicts.
See also[edit]
- mw:Help:Magic words Topics: Page names, URL data
- Module:Iteration
Pages in category "Autoreferencing templates"
The following 17 pages are in this category, out of 17 total.
- Template:AutVec
- Template:AutVec/sandbox
- Template:Derivative versions
- Template:Derived from
- Template:Derived from/Machine-readable
- Template:File
- Template:Filelist
- Template:Nearest-neighbor
- Template:Own based
- Template:Own using
- Template:Own using/sandbox
- Template:Supersedes
- Template:Vector version available