Wikia

Community Central

Subtemplate parameters set in main template

91,053pages on
this wiki

Forum page

This Forum has been archived

Visit the new Forums
Forums: Index Support Requests Subtemplate parameters set in main template
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.
Note: This topic has been unedited for 900 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.

I've been working on a template that uses subtemplates that are passed as parameters to the main template. I'll use main and sub (and subt as the name of the subtemplate param in the main template) in my examples:

main:
...
blah blah
template stuff
{{{subt}}}
more template stuff


sub:
{{{someparam}}}
...
{{{otherparam}}}
...

Basically, I want to include the subtemplate in the main template. I've gotten this part to work, BUT, I want to automatically set one of the subtemplate's params in the main template, where the include happens:

main:
...
blah blah
template stuff
{{{subt|someparam=value}}}
more template stuff

So that the param someparam in the sub template is automatically set to value when it's included, getting rid of the need to set it within the sub template declaration. As a note, this is how the template is included on a page:

{{main
|subt = {{sub
  |someparam = value1
  |otherparam = value2}}
}}

The change I want to do would eliminate the need to set the "someparam" parameter, since it would be automatically set by the main template. Of course, in the real template both "main" and "sub" have more to them, and more parameters, I'm just using these simple mockups as examples.

So, can anyone help? I can't think of any other way to do this, but it doesn't work the way I've tried (presumably because subt is just a parameter as far as main is aware, so I can't pass parameters to it).

I honestly didn't undestand what you want to do, but you can pass a parameter to a subtemplate through the main template:
In the main template:
Code
...
{{Subtemplate
|par1 = {{{par1|default}}}
}}
...
{{{par2}}}
The template call:
{{Main template
|par1 = value
|par2 = value
}}
I did something similar in this template which is composed by a main template and a sub template. leviathan_89 00:30, 13 March, 2012 (UTC)
I'm sorry, but without speaking italian it's really difficult for me to follow your code. Perhaps some actual examples from my templates would help. There are two templates, Book (main) and Book/game (sub):
Book:
{{#if:{{{skyrim<includeonly>|</includeonly>}}}|
{{!}} style="width:100%;" {{!}}
{{{skyrim}}}
{{!}}-
}}
The {{{skyrim}}} param is the Book/game template:
|skyrim = {{Book/game
  |game = skyrim
  |skill = [[Conjuration (Skyrim)|Conjuration]]
  |weight = 1
  |value = 50
  |id = 0001AFEA}}
In the Book/game template the param game sets the color of the tale elements, as well as the title text. As you can see though, I'm passing the Book/game template as a named parameter called skyrim, so it seems kinda pointless to require the game param. What I want to do is in the main template, have that automatically set, like this:
{{#if:{{{skyrim<includeonly>|</includeonly>}}}|
{{!}} style="width:100%;" {{!}}
{{{skyrim|game=skyrim}}}
{{!}}-
}}
since I know that for that instance of the subtemplate, the game param should be set to "skyrim". Unfortunately this isn't working. Does this make more sense? I'm tearing my hair out over this. {{SUBST:Signature/HaLo2FrEeEk}} 02:11, March 13, 2012 (UTC)

Around Wikia's network

Random Wiki