MDC:Custom Templates
From MDC
- How to help: contents
- Lists
- Documentation wishlist
- Editing/review to do list
- Migration list
- Guides
- Getting started
- Writer's guide
- Writing interface reference documentation
- Page naming guide
- Disambiguation pages
- Localizing MDC
- Copyrights and licensing
- References
- Wiki markup reference
- Custom CSS classes
- Custom templates
- MediaWiki extensions
- External redirects
- Needs redirect
This page lists some of general-purpose MediaWiki templates created for use on MDC. A complete list can be found on Special:Allpages by filtering to get only the pages from Template namespace. We don't need to list all of them here.
See also the Wiki markup reference and the list of custom CSS classes.
Contents |
[edit] Creating hyperlinks
[edit] Template:anch
Template:anch inserts a link to an anchor. {{anch|top}} produces <a href="#top">top</a> (top). Note that with this template you cannot choose a link description that is different from the anchor's name. The idea was to create a template that allows easy linking to other sections in a document.
[edit] Template:bug
Template:bug allows you to link to a bug on bugzilla.mozilla.org easily using this syntax: {{bug|123456}}. This gives you: bug 123456.
[edit] Template:enter-bug
Template:enter-bug lets you link to a Enter bug page on bugzilla.mozilla.org with specific product and component. For example, {{enter-bug|Core|Testing}} shows up as Core:Testing.
[edit] Template:ifmethod
Template:ifmethod lets you create a link to a particular method on an interface that's been created using our standard format for interface documentation. For example, {{ifmethod|nsIAutoCompleteSearch|stopSearch}} shows up as stopSearch().
[edit] Template:LXRSearch
Template:LXRSearch can be used (somewhat painlessly) to create an LXR search URL. The syntax is as follows: {{LXRSearch|type|param|search-string|link-text}}. The parameters are used in the following ways:
- type must be one of search (a string search through source), find (a file name search), or ident (a search through token names in Mozilla source).
- param must be one of string (for string/file name searches) or i (for token searches). If templates had some conditional power we could get away with one parameter instead of two, but they don't. An extension could probably work around this, as always.
- search-string is whatever you would type in the search box on LXR if you were doing the search there, except that spaces should be converted to +.
- link-text is the text for the link that will be created.
[edit] Template:source
Template:source allows you to link to a Mozilla source code file without having to type a long MXR URL using this syntax: {{source|browser/Makefile.in}}. This gives you: browser/Makefile.in. The text of the link is the path provided; if you want different text, then just provide a second parameter, like so: {{source|browser/Makefile.in|the browser/ Makefile.in}}, which produces the browser/ Makefile.in. Note that the link will be to the very latest version of the file in bleeding-edge code.
[edit] Linking to pages in references
- Template:jsapixref can be used to link to a page in the JSAPI Reference.
- Similarly, Template:cssxref can be used to link to a page in the CSS Reference.
- Template:npapi should be used for links in the Gecko Plugin API Reference.
- Template:funcref should be used for links to global functions (usually C++) documented on top-level pages. The template wraps the function name in a <code> tag and adds parentheses after the name. You can specify the params in the optional second argument. See the template page for examples.
- Template:interface and Template:named-interface should be used when linking to interfaces. Example: {{interface|nsIIOService}} -
nsIIOService. - Template:interface-method can be used to link to a method of an interface in case the target interface is documented according to the current guidelines. Example: {{interface-method|nsIFeedResult|registerExtensionPrefix}} -
nsIFeedResult.registerExtensionPrefix().
Usage: {{cssxref|color}}: color.
The template saves you some typing over normal pipe-link: [[CSS:color|color]].
[edit] Tagging pages
These templates should be placed at the top of a page (but below the breadcrumbs). Some templates can be also used at the top of a section.
[edit] Template:disambig
Template:disambig is used on the few disambiguation pages we have.
[edit] Template:outdated and Template:NeedsTechnicalReview
This template should be used to tag pages that are known to be (or might be) horribly outdated. It's most commonly used when an old page is migrated from mozilla.org to MDC.
The template is followed by an optional parameter, which can be used to provide details. Example: {{outdated|It was last updated in 1999.}} gives you this:
A similar template, Template:NeedsTechnicalReview is for less hopeless cases when an author or an editor was unsure if something he read or wrote was technically correct. {{NeedsTechnicalReview}} results in:
This page has been flagged by editors or users as needing technical review
Until it is fully reviewed, it may contain inaccurate or incorrect information.
[edit] Template:LockedPage
Template:LockedPage inserts a mark bar across the page that provides an explanation for why a page is locked. There are two parameters: the first is the length of time for which the page is expected to be locked, and the second is the reason why it's locked. A link to the page's discussion page is also included in the bar.
This page is marked as protected permanently for the following reason: constant spamming.
Please discuss changes that need to be made on the Discussion page.
[edit] Template:deprecated_header, non-standard_header, obsolete_header
Template:deprecated_header inserts a deprecated mark bar spread out across the page to discourage the use of, e.g., a function, method or property which is officially deprecated. The deprecated bar typically would be placed directly underneath the main page title (or breadcrumb navigation if available) of, e.g., a specific function, method or property specification page. Usage: {{deprecated_header}}. Result:
Deprecated
Similarly, Template:non-standard_header and Template:obsolete_header can be used to mark non-standard and obsolete functionality. Usage: {{non-standard_header}} or {{obsolete_header}}. Result:
Non-standard
Obsolete
[edit] Templates tagging pages in the references/guides/tutorials
There are a number of templates for almost each large collection of pages (such as the DOM reference. They typically link back to the main page of the reference/guide/tutorial (this is often needed because our breadcrumbs sometimes can't do this) and put the article in the appropriate category.
E.g.: Template:DomRef, Template:CSSRef, Template:jsapi ref header, ... (yes, the capitalization inconsistency sucks)
[edit] General-purpose templates
[edit] Template:block-title
Template:block-title can be used to create bolded text which visually serves as a title for a block in a page, does not appear in the auto-generated table of contents, and can act as a link target just as headings do. The syntax is: {{block-title|title}}, where title is whatever you want displayed. title also serves as the target for links to the section you are titling. Template:block-title is meant for use in titling Template:sidenotes, tables, images, and code blocks, particularly in places where you'll be referring to the item more than once or in places not close to the item itself.
[edit] Template:Clr
Template:Clr inserts a <br style="clear:both;" /> to make sure the text following it is below any floating images or other figures. Usage: {{Clr}}.
- Please note that using this template may mess up the layout of the whole page, e.g., if the navigational panel in default skin is floated at the left side, everything after
{{Clr}}will also be below the navigational panel.
[edit] Template:Note and Template:warning
[Template:Note]] inserts a specially-formatted "note" block into the article's text. This is intended to call out an interesting or important fact. It uses the "note" CSS class. Using the template instead of directly using the class allows us to make more changes to the appearance of the notes more easily in the future. Usage: {{Note|This is an important note.}}. Result:
Similarly, Template:warning inserts a specially-formatted "warning" block. {{warning|Danger, Will Robinson!}} results in:
As you can see, the warning block includes a large icon and is currently used for article headings (via Template:outdated). You might want to use div class="warning" instead.
[edit] Template:ref and Template:note
Template:ref and Template:note can be used to implement footnotes to articles. The footnote "number" is created using {{ref|something}}, where something should be some suitably descriptive word for whatever is being mentioned in the footnote. Then, at the end of the document, insert the following to create a numbered list for the footnotes' information:
# {{note|something}} Blah blah, text for first footnote
# {{note|something-else}} The text for another footnote
# ...
[edit] Template:deprecated_inline
Template:deprecated_inline inserts an in-line deprecated mark to discourage the use of, e.g., a function, method or property which is officially deprecated. Usage: {{deprecated_inline}}. Example:
- Item 1
- Item 2 Deprecated
- Item 3
[edit] Template:non-standard_inline
Template:non-standard_inline inserts an in-line non-standard mark to discourage the use of, e.g., a function, method, property, or attribute which has not been standardized. Usage: {{non-standard_inline}}. Example:
- Item 1
- Item 2 Non-standard
- Item 3
[edit] Template:obsolete_inline
Template:obsolete_inline inserts an in-line obsolete mark to prevent the use of e.g. a function, method or property which is officially obsolete. Usage: {{obsolete_inline}}. Example:
- Item 1
- Item 2 Obsolete
- Item 3
[edit] Template:Previous, Template:Next, and Template:PreviousNext
Template:Previous, Template:Next, and Template:PreviousNext provide navigation controls for articles which are part of sequences. For the single-way templates, the only parameter needed is the wiki location of the previous or next article in the sequence. For PreviousNext, the two parameters needed are the wiki locations of the appropriate articles. The first parameter is for the previous article and the second is for the next article.
[edit] Version information templates
- Template:fx minversion header
- Template:fx minversion inline
- Template:fx_minversion_note
- Template:js minversion header
- Template:js minversion inline
- Template:js_minversion_note
- Template:gecko minversion inline
- Template:gecko minversion header
- Template:dom_level
[edit] To remove?
[edit] Template:sidenote
Due to limitations of templates in Mediawiki which prevent templates from being nested (e.g., {{sidenote|left|See also {{bug|123456}}.}}, where the end of the inner template is incorrectly parsed as the end of the outer template), this template should no longer be used. Instead, use the following:
<div class="side-note-left">...</div> <!-- for a left-floated sidebar --> <div class="side-note-right">...</div> <!-- for a right-floated sidebar -->
