Help talk:Template format

Jump to: navigation, search
Please note

Talk pages on this wiki should primarily be used to address possible mistakes as well as missing and superseded information in the documentation.
In case you are seeking support concerning individual questions, please have a look at this page.
The SMW user mailing list is always a good idea for seeking help.

Please note

archive of previous talk on this page

Using templates: Case sensitivity of parameters

(1) Documentation Quote from the page: Examples above will fetch template values through notions like but in case named args is selected values are recognized by variables names like or instead.

Lower case, (e.g. ?population or ?area when ?Population and ?Area is used in the query) would not work in my mediawiki. At least in version MW 1.22.6 (7fe794c) and SMW 1.9.2 (40ea19e). Is that intended or a bug ?

(2) I can't get anything to work in this wiki :( ... but then I may just be tired and there is some small mistake I cannot see:

- greetings !

Daniel K. Schneider (talk)15:33, 9 May 2014

Is this still a problem?

Dan Bolser (talk)00:03, 4 November 2015

Error when value is an URL with an = symbol

Hello. Template format doesn't work fine when one of the parameters that the ASK query returns are URL type, some of them containing stuff like "". I'm not sure how Template format calls to the template, but it doesn't seem MediaWiki alike. In MediaWiki when you call a template and need to pass a URL, you call "{{template|1=}}" and works fine.

Emijrp (talk)13:00, 20 April 2014

I don't believe that this is a general problem with the "template" format. Did you try running the same query with, say, the "table" format, to see if the same problem happens there (i.e., the issue is actually with the storing of the data)? If the problem is unique to the "template" format, could you include the relevant portion of your template, that displays the URL?

Yaron Koren (talk)13:46, 20 April 2014

Templates: and

Page with ask that uses this template:

You can see the broken external links in some of the rows. All are cases of URLs with '?='.

Emijrp (talk)15:27, 5 May 2014

Could the issue be that you need to a "1=" to the "convertir fecha" template call in that 2nd link?

Yaron Koren (talk)00:35, 6 May 2014

I have added the '1=' and the result is the same, there are broken links.

Emijrp (talk)23:56, 6 May 2014

If this is still a problem, can you log this as an issue here:

Dan Bolser (talk)00:02, 4 November 2015

format=template / columns=#


|?Has Abstract=
|?Has Update Date=
|sort=Has Update Date

used to work nicely (SRF 1.5.1), letting me format my document title and place an abstract below it in with a smaller font.

As of Version 1.8, columns are ignored when format=template. I can use format=ul/ol/list with my template, but I can't get rid of the resulting bullet, number, or column that gets added.

Can format=template / columns=# support be restored?


Salq (talk)21:57, 11 June 2013

Can you log this as a bug on the dev mailing list please:

Dan Bolser (talk)00:00, 4 November 2015

...Further results

Why is "further results" always ahown as
non-wiki text
? Or is it a sloppy bug that got introduced fairly recently?
Cavila (talk)17:12, 16 January 2013

Can you link to an example?

Dan Bolser (talk)23:56, 3 November 2015

"sep" parameter

Hello. Basically the "sep" parameter doesn't work with template format. For users wishing to use custom separators between templates, they may use {{#ask: [[Located in::Germany]] | template = formatting template name goes here | format = list | sep = <br>}} (where the sep argument could be anything).

The example where I observed this behavior was on this page. (MW 1.23.2, SMW 2.0)

Relevant github report here.

Chieftain Alex13:01, 12 October 2014

Why do you need this? The point of the template format is to give you full control of layout, obviating the need for options like sep. (Unless I misunderstood).

Dan Bolser (talk)23:54, 3 November 2015

Clarifying something with named args

I'd like to suggest that in the Usage for named args section the sentence "Note, the question mark is required!" be changed to something like "Note, the question mark is required, even if you supply an alternate name!". This caused me some confusion because when you specify names in a table the question marks are removed from the table, so I assumed parameters sent to templates would work in a similar fashion, but they do not. This behavior seems odd to me because it prevents SMW from using templates that are also meant for normal use by users without modifying those templates to accept alternative parameters with question marks, but that's a discussion for elsewhere. --Sigilbaram (talk) 22:34, 8 April 2015 (CEST)

Sigilbaram (talk)22:34, 8 April 2015

Please be bold and feel free to make excellent changes like this yourself! (However I just did it :-)

Many thanks, and please don't hesitate to suggest (or do!) similar changes!

Dan Bolser (talk)23:52, 3 November 2015

Possible documentation typo, with template argument ordering

Maybe I'm missing something (not uncommon) but the article's example template (Template:Query output demo) lists the argument order as

{{{2}}} people squeeze into the {{{3}}} of {{{1}}}.

but shouldn't it be:

{{{3}}} people squeeze into the {{{2}}} of {{{1}}}.

in order to get the stated output? I would simply edit this myself, but I'm new and have no confidence in my technical knowledge of SMW.

Wm (talk)19:56, 10 October 2015

> but shouldn't it be: {{{3}}} people squeeze into the {{{2}}} of {{{1}}}.

No, the order is correct because if you look at the data then a subject (1) (such as Amsterdam) has somewhere in its text declared that a population is of "783,364" within an area of "219 km²". (The order of the annotation that appears in a subject has no relevance but the order in the ask query determines its position for the template placeholder.)

The ask query:

{{#ask: [[Category:City]] [[Area::+]] [[Population::+]] -> (1)
 | ?Population=Inhabitants -> (2)
 | ?Area#km²=Size in km² -> (3)

will contain the subject at position (1), the population at (2), and the area at (3) hence the positional fix when "{{{2}}} people squeeze into the {{{3}}} of {{{1}}" gets answered. The template output will generate " 783,364 people squeeze into the 219 km² of Amsterdam.".

> I would simply edit this myself, but I'm new and have no confidence in my technical knowledge of SMW.

If you are unsure about what works and what doesn't, you are welcome to use [0] for such experiments. Don't be a stranger if comes to testing or questions and of course some documentation will need a nudge to make it easier for the less experienced users to find its way around SMW but here we are counting on users like you that with the help of a fresh pair of eyes can improve the situation.


MWJames (talk)03:26, 11 October 2015

Using Template format to create a working expression

I am trying to use the Template format type with intro and outro to create an #expr that adds up the results of my semantic query, but the #expr just prints out as text, it does not execute. It's a simple move to just add the list of property ranks from a valuerank query. I felt like I pulled it off, but I just wind up with this:

{{#expr: 0 + 14 + 5 + 4 + 3 + 3}}

Is it possible to get this expression to execute and give me a total number as the printou while using the template format? or is there a better way to add up the instances of a Property printout and get a total count? I am all ears.

Jcantroot (talk)16:30, 17 July 2015

> #expr just prints out as text, it does not execute

I'm guessing (the description isn't clear about this) that you are using the template to generate an output similar to Intro -> {{#expr: Query -> 0 + 14 + 5 + 4 + 3 + 3 Outro -> }} which will be a text component and not a parser expression (even though it appears as a normal expression).

> to execute and give me a total number as the printou while using the template format?

Demo:Template_with_tabular_output_and_math_functions might help.

MWJames (talk)17:05, 17 July 2015

Yes you pretty much nailed it. My intro was declaring {{#expr: 0 -> my template was -> + {{{rank}}} and my outro closed it up -> }}. It looks like that math function demo may help we get to where I need to be. I am going to check that out. Thanks!

Jcantroot (talk)17:46, 17 July 2015

Templates with paramaters as an "introtemplate"

The | introtemplate = feature is not well documented and does not seem to accept templates with paramaters (such as {{Template|option1}}, for example) Is this correct? Is there a workaround?

Dbi (talk)18:27, 26 August 2014

That's true. A workaround always depends on what you are trying to do. Do not forget the mailing list but be more verbose.

[[kgh]] (talk)09:44, 27 August 2014

Using template with paramaters as an introtemplate

Short version: It seems like I can't use templates with paramaters in the | introtemplate={{template|param}}. Is this correct? Is there a workaround?

Long version:

I'm trying to insert a template with paramaters as the introtemplate option. I would like to create a section heading if there are more than zero results returned by the ask query, and not create a section heading if zero results are returned. Here is my code:

{{#ask: [[Property1::Value1]] [[Category:Category1]] | introtemplate={{createHeading|Value1}} | link=none | limit=100 | format=list | sep=  | template=template1 | userparam=120px }}

The createheading template is as follows:


The output is as follows:


The paramater is correctly passed to the template, but the {{ and }} still remain.

Omitting the braces in the line | introtemplate={{createHeading|Value1}} breaks the statement. Omitting the braces and the paramater works perfectly fine if the template takes no arguments. Is there any way to do this, or any workaround? I am on version 1.21.11.


Chip (talk)18:09, 20 August 2014

The introtemplate parameter can only take the name of the template to be inserted. So if the template is called "createheading" you can only do |introtemplate=createheading. I am surprised that you even got that far with your output.

[[kgh]] (talk)09:40, 27 August 2014

Quotes in code example are confusing and shouldn't be there (I think)

The first example on the page uses this snippet:


Those double quotes are misleading, as they shouldn't be there. It seems to me that this was a copy-paste from a section where templatename was in italics (hence the quotes). Because it's wrapped in a pre tag, these are shown as-is. So I changed that :)

Joost (talk)14:34, 18 March 2014

This was probably the case. I think the examples could even do without italics, but it does not harm at all. So ... :)

[[kgh]] (talk)18:16, 18 March 2014