Templates w/ Parameters for external links

Templates w/ Parameters for external links

Hi Will,

Is it possible to have a template parameter where it will will in an external link such as this:

[[Template:Permalink]] => [[File:Permalink.svg|15px|link=URL]] [URL Permalink]

INPUT

{{Template:Permalink|http://www.eric.ed.gov/ERICWebPortal/detail?accno=ED461311}}

OUTPUT

[[File:Permalink.svg|15px|link=http://www.eric.ed.gov/ERICWebPortal/detail?accno=ED461311]] [http://www.eric.ed.gov/ERICWebPortal/detail?accno=ED461311 Permalink]

Just wanting to make the process of creating pages easier where I can just call the template and then add the url.

Thanks!

- Z

Riacale17:34, 29 March 2011

Hi Zack,

To set up named parameters in a template, you put the name in 3 brackets, such as {{{link}}}. When you call the template, you would then assign a value to the parameter url. For example, I created a test/demo template for your example called Template:Perma. If you check out that template, you'll see that it has two named parameters, link and name. For the purpose of this discussion, I have the template create two outputs; one wit the raw url link and one with a named link (which you might not want). If I wanted to call that template here, I would use the following protocol:

{{Perma
|link=http://www.google.com
|name=google.com
}}

Here is what that template looks like:

Permalink.svg http://www.google.com

Permalink.svg google.com

Please let me know if this makes sense and if I understood your question correctly.

Cheers,

-Will, WikiAdministrator18:36, 29 March 2011
 

Thanks! I'm also wondering if there's a way to hyperlink the image with the URL parameter.

Riacale19:20, 29 March 2011

Yep, in the image code on the template page, [[File:Permalink.svg|15px|link=URL]], change the link=URL part to link={{{same parameter name as the url}}}. So in my Template:Perma example (which I've updated to have the icon link), I've used the following code:

[[File:Permalink.svg|15px|link={{{link}}}]] {{{link}}}

[[File:Permalink.svg|15px|link={{{link}}]] [{{{link}}} {{{name}}}]

To call that template here, I would past the following code:

{{Perma
|link=http://www.google.com
|name=google.com
}}

Here is what it looks like live:

Permalink.svg http://www.google.com

Permalink.svg google.com

Let me know if that makes sense.

Best,

Will

-Will, WikiAdministrator20:08, 29 March 2011
 

Great! I understand now. From what I read, I thought I needed to have another template to pull in stuff for the parameters.

Thanks again!

- Z

Riacale21:08, 29 March 2011