Template:Link

From PCSAR

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
-
<noinclude>
+
<noinclude>{{documentation}}</noinclude><includeonly><!--
-
Template to create a link to a page (arg 1) and use its preferred description or arg 2 or arg 1 if no such name is defined.
+
 
-
</noinclude><includeonly>[[:{{{1}}}|{{default|{{default|{{#ask: [[{{{1}}}]]
+
create a link.
-
| ?Desc =
+
 
-
| link=none
+
-->[[<!--
-
}}|{{{2|}}}|}}|{{{1}}}|}}]]</includeonly>
+
 
 +
if it's an Image: link, don't use the image, create a link to it.
 +
 
 +
-->:<!--
 +
 
 +
what to link to
 +
 
 +
-->{{{1}}}<!--
 +
 
 +
Text to display
 +
 
 +
-->|<!--
 +
 
 +
First choice of:
 +
 
 +
-->{{default<!--
 +
 
 +
Arg 2, if preset
 +
 
 +
-->|{{{2|}}}<!--
 +
 
 +
The text of the page's "Page description" attribute
 +
 
 +
-->|{{#ask: [[{{{1}}}]]
 +
| ?Page description =
 +
| link=none
 +
}}<!--
 +
 
 +
last choice: the page name itself
 +
 
 +
-->|{{{1}}}<!--
 +
-->}}<!--
 +
 
 +
end of link
 +
 
 +
-->]]<!--
 +
 
 +
--></includeonly>

Revision as of 02:50, 7 February 2012

This is the documentation for the template Template:Link

Template:Link/Doc:
Related Templates
Link/Create Create from template
Link/Desc Use page's description
Link/Create+Desc Combine Link/Create and Link/Desc
Link Default; same as Link/Desc

This template creates a link to another wiki page.

Contents

Common usage

Most commonly this template is called as {{link|Page}}. In the form {{link|Page|Text}} it creates a link to Page but displays the link as Text.


You type... You get...
{{link|Main Page}} 
Main Page
{{link|Main Page|see this page}} 
see this page


It is also commonly used to provide links to file descriptor pages. See Help:Linking to files.

You type... You get...
{{link|Image:Demo Sunflower.png}} 
Image:Demo Sunflower.png


{{link}} is an alternative shortened name for {{Link/Desc}}. Either can be used.

Features

This template is similar to creating a link with double square brackets: [[Page]].

Double square brackets requires extra decoration with a leading colon when the page is an Image:, File: or Category:. This template handles those types of pages without any extra work; no leading colon is necessary.

If no Text is provided, the link is shown as the Page name. For subpages (e.g. Main Topic/subtopic) the link text is just the subtopic.

The page can have a description and that description will be displayed as the text of the link. The description is taken from the Property:Page description which can be set using Template:desc, etc.

The link can lead to a previous version of a wiki page, using the parameter RevisionID.

For multipage PDF's the link can lead to a specific page, using the parameter PageNum.

As Template:Link/Create or Template:Link/Create+Desc, links to pages that don't exist yet can specify default text for their creation.

Parameters

The template {{Link|Page|RevisionID=id|PageNum=number|Text|Desc=description}} uses the following parameters:

Page 
the page to link to
RevisionID 
(optional) The revision to link to. This is used to link to an old version of an existing page. Revision ID's can be found on the "history" tab of the page in question, as "oldid". Revision ID's are unique across all pages, so the Revision ID also specifies the Page. If the Revision ID is provided, the Page does not need to be specified unless it is to provide the link text.
PageNum 
(optional) if Page is a file that supports multiple internal pages, this parameter will link to the specified internal page
Text 
(optional) the text to display as the link
Desc 
(optional) the text to display as the link if the page does not have a description and Text is not supplied. There is no point to specifying both Text and Desc.

Examples

For illustration purpose, the following demonstration pages have been set up:


You type... You get...
{{Link/Desc|Demo/Page with description}} 
Described page
{{Link/Desc|Demo/Page without description}} 
Page without description
{{Link/Desc|Demo/Page with description|this page}} 
this page
{{Link/Desc|Demo/Page without description|this page}} 
this page


Here's how it would work if you had used square brackets instead. (The difference between this table and the previous one is only in the first case.)

You type... You get...
[[Demo/Page with description]] 
Demo/Page with description
[[Demo/Page without description]] 
Demo/Page without description
[[Demo/Page with description|this page]] 
this page
[[Demo/Page without description|this page]] 
this page


Using Desc:

You type... You get...
{{Link/Desc|Demo/Page with description|Desc=this page}} 
Described page
{{Link/Desc|Demo/Page without description|Desc=this page}} 
this page
{{Link/Desc|Demo/Page with description|That Page|Desc=this page}} 
That Page
{{Link/Desc|Demo/Page without description|That Page|Desc=this page}} 
That Page


Using RevisionID:

You type... You get...
{{Link/Desc|RevisionID=1}} 
linklink=
{{Link/Desc|Main Page|RevisionID=1}} 
Main Pagelink=
{{Link/Desc|Main Page|main|RevisionID=1}} 
mainlink=


Using PageNum:

You type... You get...
{{Link/Desc|Main Page|PageNum=2}} 
Main Page


Implementation

Helper templates:

Icons:


To see how this template is implemented, edit this page and examine the portion between <includeonly> and </includeonly>.

Personal tools