Template:Mdnbox/doc

From MozillaWiki
< Template:Mdnbox
Revision as of 19:08, 25 November 2014 by Lakrits (talk | contribs) (→‎Examples: Scrubbed the table.)
Jump to navigation Jump to search
Edit-copy green.svg
This is a documentation subpage for Template:Mdnbox.
It contains usage information, categories and other content that is not part of the original template page.

Usage

{{mdnbox}} produces a right-hand adjusted, floating message box, telling the reader there is a document on the current subject (either the wikipage's name, or an user-defined title) on Mozilla Developer Network (MDN).

Parameters

There are 1 unnamed and 8 named parameters (see the table below), none of which is required for the template to work. However, if the template is not configured correctly, it will most likely cause the document link to break.

Parameter Description
1 Custom link text; unnamed parameter
lang Language code
d For exclusion of the page level /docs
l1 Custom page address/first page level
l2l5 Additional page levels 2–5
sh Page subheader/anchor name
Copy-paste templates
Size Code
Basic {{mdnbox|lang= |''1'' }}
Common {{mdnbox|lang= |l1= |l2= |''1'' }}
Full {{mdnbox|lang= |d=no |l1= |l2= |l3= |l4= |l5= |''1'' }}

Custom link text

1

Custom text string that will show as link text. The parameter is unnamed, so no parameter name needs to be entered.

Note:

  • If this parameter is left out, the link will be named after the current page. The automatically generated name will include subpages, but not the namespace.

If, for example, you place the template on the subpage L10n:Dashboard/Apps/Projects, and don't define any link text of your own, the link name will be "Dashboard/Apps/Projects".

Usage
  • {{mdnbox|text}}

Language

lang

It is possible to specify a MDN locale code for the link (e.g. de for German or sv-SE for Swedish). If this parameter is left out, the link will be redirected at MDN to either the locale of the user's Firefox browser, or (if there is no translation of that webpage for the user's locale) to the English default locale (en-US). An up-to-date list of Mozilla's web locale codes can be found at the Mozilla Web Localization Dashboard.

Usage
  • {{mdnbox|lang=locale code}}

Exclude the /docs page level

d

Most pages on MDN are placed as documents under the page level /docs, for documents. But some sections of the website don't use that level. This template will, as default, include /docs in the URL, but it is possible to suppress that inclusion by defining this parameter (d) to the value no. Any other value, e.g. yes, null, or " " (empty), will be ignored (i.e. the /docs level will still be included).

So, only use this parameter if you need to exclude the /docs level frpm the URL. If you want to keep it, you don't need to do anything, it will be inserted automatically.

Usage
  • {{mdnbox|d=no}}

Page address

There are two ways to enter the page address in the template, by entering the entire address part for the webpage in one string, or by defining each page level separately.

One address string

l1

If you want to link to a webpage under the websites base address, and enter the page address as a single string, you can use the l1 parameter ("l1" as in level one).

To, e.g., link to the MDN page Localizing with Verbatim (developer.mozilla.org/en-US/docs/Mozilla/Localization/Localizing_with_Verbatim), you enter Mozilla/Localization/Localizing with Verbatim, which is the page address under the level developer.mozilla.org/en-US/docs/. The name you type in must be the same as the page's address part in the location bar.

Limitation
  • Any linkpart pointing to an anchor/subheader (i.e. a link that includes a number sign, #) will break the link. If you want to link to an anchor/subheader, use the sh parameter (see below).
Usage
  • {{mdnbox|l1=custom address string}}

Defined page levels

l1 + l2–l5

Sometimes, the page address is particularly long or complicated. If you want to enter the address in a structured way, you can use the parameters l1l5 in order to define up to 5 page levels ("l2" as in level two, etc.) under the level developer.mozilla.org/docs/ (or under developer.mozilla.org/, if the /docs level is excluded).

To, e.g., link to the MDN page Localizing with Verbatim (developer.mozilla.org/en-US/docs/Mozilla/Localization/Localizing_with_Verbatim), you enter the values Mozilla, Localization, and Localizing with Verbatim (which is the page address under the level developer.mozilla.org/en-US/docs/), defining the parameters l1=, l2=, and l3=, respectively. That will insert the string […]/Mozilla/Localization/Localizing with Verbatim into the URL.

Limitation
  • Any linkpart pointing to an anchor/subheader (i.e. a link that includes a number sign, #) will break the link. If you want to link to an anchor/subheader, use the sh parameter (see below).
Usage
  • {{mdnbox|l1=level 1|l2=level 2|l3=level 3|l4=level 4|l5=level 5}}

Page anchor/subheader

sh

This parameter allow you to link to a named section of an article, i.e. a subheader or an anchor in the format Page_name#Section_name. Just enter the name of the section, i.e. don't include the number sign (#). That is inserted automatically.

For example, to link to the article section Additional tasks on the page Localizing with Verbatim, you enter the value Additional tasks, which will be output as #Additional tasks.

Usage
  • {{mdnbox|sh=anchor/subheader title}}

Examples

(By parameter)

MDN logotype Find documentation about developing for the web on  MDN text banner
1

{{mdnbox|Custom link text}} gives


MDN logotype Find documentation about developing for the web on  MDN text banner
l1

{{mdnbox|Localizing with Verbatim|l1=Mozilla/Localization/Localizing with Verbatim}} gives


MDN logotype Find documentation about developing for the web on  MDN text banner

lang

{{mdnbox|''Localizing with Verbatim'' in Korean|lang=ko|l1=Mozilla/Localization/Localizing with Verbatim}} gives


d

MDN logotype Find documentation about developing for the web on  MDN text banner
1. No param
{{mdnbox|The MDN project|l1=MDN}} gives




MDN logotype Find documentation about developing for the web on  MDN text banner
2. Empty
{{mdnbox|The MDN project|d=|l1=MDN}} gives




MDN logotype Find documentation about developing for the web on  MDN text banner
3. No value
{{mdnbox|Add-ons|d=no|l1=Add-ons}} gives




MDN logotype Find documentation about developing for the web on  MDN text banner

l1–l5

{{mdnbox|Localizing with Verbatim|l1=Mozilla|l2=Localization|l3=Localizing with Verbatim}} gives


MDN logotype Find documentation about developing for the web on  MDN text banner

sh

{{mdnbox|Localizing with Verbatim: Additional tasks|l1=Mozilla|l2=Localization|l3=Localizing with Verbatim|sh=Additional tasks}} gives

See also