I have the result of a semantic query. For one of the properties, a comma separated list, I want to separate each item and pass it as a parameter to a template. However, I am struggling to find a way to do this.
For example;
Query:
{{#ask: [[Category:Something]] [[Has title::Somethingelse]]
| mainlabel=-
| ?Has property
| link=none
| format=template
| template=plainText
}}
The plainText template will have the result, which is a comma separated list. Now, from the plainText template I would like to separate the comma separated list and put each value as a parameter into another template.
I have tried using {{#arraydefine:key|values|delimiter|options}}
but when I pass {{#arrayindex:key|0}}
to the template, the value is not passed. The whole array is passed separated by 0. I have also tried using {{#vardefine:
etc but this also does not pass the variable.
My question boils down to, how to pass a variable to a template?
Thanks,
The separation needs to be done in the template. If you use anonymous args like in http://semantic-mediawiki.org/wiki/Template:Query_output_demo
Your params can be fetched with defaults like this:
Now one of your params is a comma separated list. You might want to use the
parser function to get to the different parts of the CSV. Lets assume the second parameter has your csv then:
will provide the fields.
For this to work you need the extension
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##explode
and to enable it according to the instructions there.