Semantic mediawiki #ask query: displaying nested properties for the same query

I would like to display in the same request properties of the page that is associated with the requests of the pages on which the request is being executed.

Let's say I would like to request all the pages in the City category that are in Germany, and I want to display the page name, but also want to display German surface data, for example.

Something like this: {{#ask: [[Category:City]] [[location::Germany]] |?mainlabel |?Location.surface }}

I know this does not work, but you can see what I want to achieve.

+4
source share
1 answer

I am not sure if there is a way to nest requests directly in other requests. The usual way to use it is to use a template. Thus, you can define a template (or a subpage of the template, if it is included in the template) called {{tablerow}} , which consists of:

 <includeonly> |- valign="top" | [[{{{1|}}}]] | {{#show: {{{1|}}} | ?surface }}</includeonly> 

The <includeonly> tags are important for reasons that I really donโ€™t understand, sometimes errors occur if you do not leave them. Then you just run the #ask request with format = template . (You can build a title in the request, but itโ€™s easier for me to simply set it outside.)

 {| class="wikitable smwtable sortable" |- valign="bottom" ! [[City]] ! [[Surface]] {{#ask: [[Category:City]] [[location::Germany]] | format = template | template = tablerow | link = none }} |} 

This will delete every result returned by the request through the template as {{{1}}} and will generate a string based on this. If you have other data to return from the main request, the additional properties that you request will exit as consecutive unnamed parameters (therefore, if you enable | ?population , this will go into the template as {{{2}}} and it will need to be add to the line structure or it will be deleted).

+3
source

All Articles