Open main menu
Warning! Please do not post any new comments on this page. This is a discussion archive first created in 2009, although the comments contained were likely posted before and after this date. See current discussion.

Parameter help needed...

Well this is hard to explain, but basically, I want to insert a template into an article with parameters, but I also want the parameters to be, well accessible to a template included in the template that's included in the article. But when I try that, the second template doesn't have access to the parameters specified for the first template. What could should I use to have all of the parameters for the first template automatically the parameters for the second template? 69.68.196.73 04:53, 10 December 2008 (UTC)

See Help:Template#A_parameter_value_depending_on_parameters.--Patrick (talk) 08:54, 4 January 2009 (UTC)

Display problem when calling single paramters from a template.

Essentially, I'm trying to use a template as an array. I embedded a menu in my sidebar for my private wiki. The links in the menu need to be congruent with several other pages on the site, but updating both the menu source page (a normal wiki page) and every other instance of the links can be tedious. I want to replace the links on the menu, and the other instances of those links with a call to a template and a parameter. I want to use a single template with multiple paramters. By given each parameter in the template a default value, I hope to be able to update the default values in the template and, therefore, update all of the relevant links:
Template:links

{{{lan|page1}}}
{{{wan|page2}}}

Then, on my menu, or another page, I would put this:

[[{{links|lan}}]]

The output for this is not what I was hoping for:

[[page1page2]]

Problems with this method:

  1. Whenever "lan" is called alone or "wan" is called alone, the defaults for both "lan" and "wan" are displayed. (i.e. it returns the whole template).
  2. If templates contains parameters that span multiple lines, particularly empty parameters, their line formatting is retained in the output.

Example:

Template
{{{wan|page1}}}
{{{wan2|}}}
{{{wan3|}}}
{{{lan|page2}}}
Call to template

{{links|wan}}

Result
page1


page2

I have a feeling that I have over simplified this. If you can point me in a better direction (if one exists for my needs), please do. I appreciate your consideration. Sterlings 19:52, 9 February 2009 (UTC)

{{links|lan}} means {{links|1=lan}}, so it does not assign a value to a parameter named lan.--Patrick (talk) 01:53, 26 February 2009 (UTC)
That part I think I understand, but what really bothers me now is that even if I put {{links|1=lan}}, because "wan" is still part of the "links" template, it is implicity called even though I may not want it. Does anyone know of a way to only pull one paramter from a template at time and make that determination from the template call? Therefore, {{links|lan}} would produce "page1" and not "page1page2" as it currently does. By the same method, {{links|wan}} should produce "page2" and not "page1page2" as it currently does. I'm probably asking too much from a single template, but I have not seen this question asked anywhere else.Sterlings 23:23, 26 February 2009 (UTC)
If there only two cases you can use e.g. {{#ifeq:{{{1}}}|lan|page1|page2}}. If there are more cases of which only one applies in every call you can use #switch. If there are independent conditional parts you use #ifeq several times.-Patrick (talk) 16:00, 4 March 2009 (UTC)

Help:Template/2009#Self-transclusion

Does anybody know where in the parser code can we make a change so that self-transclusions are allowed? Hillgentleman 02:38, 12 March 2009 (UTC)

arguments count?

is there a way to count how many arguments ({{template|a|b|c|d|...}} => {{{1}}},{{{2}}},...) are used in the call of a template? 89.2.186.67 17:28, 12 March 2009 (UTC)

If empty counts as undefined the number of unnamed arguments (up to a maximum) can be found using an expression like {{#expr:{{#if:{{{1|}}}|1|0)}}+{{#if:{{{2|}}}|1|0)}}+{{#if:{{{3|}}}|1|0)}}}}.--Patrick (talk) 07:19, 14 March 2009 (UTC)
In the spirit of Patrick's solution, I have created {{Argcount}}. —Anonymous DissidentTalk 10:50, 15 March 2009 (UTC)
Of course, for now, the template won't really function because it can only be applied to itself. I wonder if there is a way to implement this another way. —Anonymous DissidentTalk 10:55, 15 March 2009 (UTC)
The only way to pass on arguments to the next template is by something like the call {{argcount|1={{{1|}}}|2={{{2|}}}|3={{{3|}}}...}}. However, you may customise your template argcount so that it can be substituted. Hillgentleman 02:25, 16 March 2009 (UTC)

archiving as subpages

Since this page gets tonnes of questions, why don't we archive them as subpages and then we would have a set of faqs via the prefixindex? Hillgentleman 08:32, 14 March 2009 (UTC)

Return to "Template/2009" page.