Community Central

Admin Forum:Template with if and two parameters

18,824pages on
this wiki
Add New Page
Add New Page Talk0

This Forum has been archived

Forums: Admin Central Index Technical Help Template with if and two parameters
Wikia's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.

I've been trying for days to fashion a template to be used to link to another wiki (it's supposed to be an easier alternative to w:c:*). All I want is for the template to replicate the normal wikilink function, with two parameters:

  • {{shortcut|link to page|text to display}}

And I actually managed to do that. Problem is, I also want the template to know when there is no second parameter, and use the first one instead:

  • {{shortcut|page}}

No dice. I've tried a lot of things, including #if, #ifelse, and #string. The output is either parameter 1 in both cases, or parameter 2 in both cases, or both parameters at once, or a copypaste of the template code. Nothing has worked and it's driving me batty. Any ideas? --Tulipclaymore 18:32, October 23, 2011 (UTC)

Do you mean something like [[w:c:domain:{{{1}}}|{{{2|{{{1}}}}}}]]? This will use the name of the page if nothing is specified for the second parameter.  Monchoman45  Talk  Contribs  Skystone  18:36,10/23/2011 
Um, yes. Exactly like that; fed that into my wiki and it works perfectly. Thank you.
I hadn't even thought of doing it like that. Just out of curiosity: is there a way for my approach to work (an if function that returns two different strings depending on whether a second parameter is given or not)? --Tulipclaymore 18:50, October 23, 2011 (UTC)
An if function would work, although it would be redundant in this case. Example: {{#if: {{{2|}}}|{{{2}}}|{{{1}}}}} --Gardimuer { ʈalk } 21:24, October 23, 2011 (UTC)
Thank you. I could swear I had tried something similar, but I guess not (or I got confused with the number of brackets). --Tulipclaymore 08:08, October 25, 2011 (UTC)

Also on Fandom

Random Wiki