Difference between revisions of "Template:Shortcut/doc"
en>DannyS712 m (Reverted edits by 2604:3D08:5680:3D0:A521:FBC7:473F:B297 (talk) to last version by Hildeoc) |
m (1 revision imported) |
(No difference)
|
Latest revision as of 06:21, 3 January 2019
This is a documentation subpage for Template:Shortcut. It contains usage information, categories and other content that is not part of the original template page. |
This template is used on approximately 21,000 pages, so changes to it will be widely noticed. Please test any changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Please consider discussing changes on the talk page before implementing them. |
This template uses Lua: |
This template uses TemplateStyles: |
Related pages |
---|
Wikimedia Commons has media related to Template:Redirects. |
This is the documentation for {{shortcut}} and its sister templates. The shortcut family of templates is put into context here, but they each have their own documentation pages, see below.
A shortcut template is similar to the {{anchor}} template, but it adds a visual box graphic to the rendered page, as well as providing an alternative name. Creating a redirect page is a requirement to fulfill the shortcut mechanism.
Usage
The characteristics of the box graphic are determined by which of the family of shortcut templates are chosen. For example, the policy shortcut box has the word policy on it for use on policy pages. The graphic alignment of the box depends on the whether it's a shortcut or a shortcut-l:
- {{shortcut}} – right-aligned box
- {{shortcut-l}} – left aligned box
- {{policy shortcut}} – shortcut that also says "policy"
- {{Ombox/shortcut}} – shortcut that embeds into message boxes
This template should not be used for articles in the main namespace, because the graphic produces an unavoidable self-reference.
- Insert the shortcut template.
- Create a redirect page with the {{R from shortcut}} template suffixed to the redirect. Name the page after your shortcut name. Include the namespace name in both the shortcut name and the redirect page name. For example, substitute your own shortcut name as the title of the page, and substitute the proper namespace, then add the REDIRECT as the top-line on your redirect page, and the category to the third line of the redirect:
#REDIRECT [[Namespace:Title of page with#Optional very long section name]]
{{R from shortcut}}
- Verify operation. Note that shortcut templates should display in all capitals, but operate without all capitals.
Notes Shortcuts are used mainly on user pages and talk pages in reference to the Wikipedia, Help, and Portal namespaces. These templates inform about the shortcuts available to the page they are on. For example, WP:SHORT redirects to Wikipedia:Shortcut and therefore, Wikipedia:Shortcut renders a shortcut box listing WP:SHORT. It is a self-reference that is normally avoided in the main article namespace.
The point of these templates is not to list every single redirect for a page (indeed, that's what Special:WhatLinksHere is for). Instead, they should list the most common and easily remembered redirects.
For policy pages, one can use the {{policy shortcut}} template, which takes up to ten (10) shortcuts as parameters. Be careful not to use a policy template on a guideline or essay.
Parameters
{{shortcut}} takes the following parameters:
1
,2
,3
... - the shortcut links.msg
- an unlinked message that goes after the shortcut links.category
- set to "no", "n", "false" or "0" to suppress error categories.
Examples
Code | Result |
---|---|
{{Shortcut|WP:SHORT}}
|
<templatestyles src="Shortcut/styles.css"></templatestyles> |
{{Shortcut|WP:V|WP:VERIFY|WP:SOURCE}}
|
<templatestyles src="Shortcut/styles.css"></templatestyles> |
{{Shortcut|WP:V|WP:VERIFY|msg=A message}}
|
<templatestyles src="Shortcut/styles.css"></templatestyles> |
Anchors
These templates automatically add an anchor for each shortcut name parameter. For example, if a shortcut box with the shortcut WP:SHORT is placed on the page Wikipedia:Shortcut, then the link Wikipedia:Shortcut#WP:SHORT will take you to the position in the page where that shortcut box is placed.
For instance, try this link: #WP:SHORT
This makes it easier to create a shortcut for a section of a page, because you can refer to the anchor when creating the shortcut redirect itself. Like this:
#REDIRECT [[Pagename#WP:SHORT]] {{R from shortcut}}
Positioning
This template is usually placed below the section header or at the top of a page.
Before July 26, 2010, when the anchor was inside the box, this caused the section header to scroll above the page window. Fixes for this issue included:
- Placing the shortcut above the section header; a bit confusing when editing
- Creating the redirect to the section header, not the shortcut; this would break if the section header was renamed
- Placing an {{anchor}} in the section header that duplicated the shortcut
These fixes are no longer needed, but do not break the current implementation.
See also
- Wikipedia:Shortcut – The how-to guide and guideline about how and when to create shortcuts and shortcut boxes. A must-read for anyone handling shortcuts.
- {{Anchor}} – a way to overcome the otherwise permanent fact that section titles are the only way to link to a section
- {{Ombox/shortcut}} – for embedding into message boxes
- {{Policy shortcut}} – for shortcuts to sections of policy pages
- {{R from shortcut}} – for placement on the redirect page
- {{Shortcut-l}} – for left aligned normal shortcuts
- {{Template shortcut}} – used for shortcuts/redirects to a template page