Edit infobox template
Hidden category: Drafts. Namespaces Manual Discussion. Views Read Edit View history. Bug tracker Code docs Code repository Statistics. Add links. Note: This tutorial is not for novice users. Parameters for new rows can then be inserted in future without having to renumber existing parameters. For example:. A row with a label but no data is not displayed. This allows for the easy creation of optional infobox content rows.
To make a row optional use a parameter that defaults to an empty string, like so:. This way if an article doesn't define the population parameter in its infobox the row won't be displayed. For more complex fields with pre-formatted contents that would still be present even if the parameter wasn't set, you can wrap it all in an " if" statement to make the whole thing vanish when the parameter is not used.
For instance, the " if" statement in the following example reads " if:the parameter mass has been supplied then display it, followed by 'kg'":. For more on if, see here. You can also make headers automatically hide when their section is empty has no data-row showing. So, header1 will be shown if any of item1, item2, or item3 is defined. If none of the three parameters are defined the header won't be shown and no empty row appears before the next visible content.
This will serve as an empty header and separate it from the subsequent items. This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. Multiple class names may be specified, separated by spaces, some of them being used as selectors for custom styling according to a project policy or to the skin selected in user preferences, others being used for microformats.
To flag an infobox as containing hCard information, for example, add the following parameter:. And for each row containing a data cell that's part of the vcard, add a corresponding class parameter:. See Wikipedia:WikiProject Microformats for more information on adding microformat information to Wikipedia, and microformat for more information on microformats in general.
They present important points in an organized and quickly readable format. Infoboxes are generally made using templates , to create consistency across a community. Fandom has developed a consistent way to code infoboxes, called Portable Infoboxes , to enable them to display well across different devices, which this page details.
There are no changes to how you use an infobox on an article — instead, the changes affect how it is written on a template page. Fandom considers use of Portable Infoboxes to be standard for their communities, and safe and stable for common practical use. A tool to help with the migration of existing infoboxes has also been created.
More information about this can be found on Help:Infobox migration. You can add an infobox to an article the same way as you would any other template, either via the editor's built-in tools, or through the editor's source mode. Meanwhile, in source mode, you would generally start by copying the syntax from the template's documentation normally found towards the bottom of the template's page and pasting it into an article, changing the words after the equals signs to provide the desired information.
For example:. With Portable Infoboxes, this works similar as with any other template. The template page markup is a little different, as detailed below. First, start a new template with any name you like. To do this, create a new page with the title "Template:[name of your choice]" e. We'll begin with a basic 'stacked' infobox, with a title and an image:. This wikitext will tell your template to use name and image variables for title and image elements.
After adding one last field with source set to first and label to First seen , we end up with the following:. We can now use the template in an article, inserting the following parameters to get a working infobox:. Any field or element without a value will automatically be hidden.
When all elements are empty the infobox itself will not appear. Infoboxes using this kind of code are automatically styled, taking cues from your community's custom theme.
0コメント