Forum:Subtemplate parameters set in main template

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

more template stuff

sub: ...

...

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

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:

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 ...

...


 * The template call:


 * I did something similar in this template which is composed by a main template and a sub template.


 * 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:


 * The param is the Book/game template:

|skyrim =


 * 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:


 * 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. 02:11, March 13, 2012 (UTC)