Help talk:Displaying information

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

Displaying nested properpies on the same query

Hi everyone, I would like to display in the same query properties of a page which is related to the pages im querying for.

Let's say I would like to query all the pages in the City category, which are located in Germany, and I want to display the title of the page, but also I want to display the surface data of Germany, for example.

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

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

Thanks in advance!


Okay... I appear to be missing something.

Let's say we have a page with multiple Has Related Page values. In other words, a one-to-many relationship between pages. If I perform a {{#show query or whatever to return those values, how would I format them into an unordered list? Simply typing format=ul doesn't work, since the values are for the same page. A simple template=whatever doesn't work, since all values are passed as the first argument.

This seems to me like it'd be one of the simplest things for a user to be able to accomplish, and yet I'm unable to find any information concerning it. I figure I'm missing something obvious. 06:08, 12 August 2010 (UTC)
The options are actually pretty limited right now, sadly, for displaying multiple values for the same page. What do you mean by "unordered list", though? Yaron Koren 13:48, 12 August 2010 (UTC)

Adding a 'constant' column to the output of a query?

Is there a printout statement for creating an output column containing the same value for every query result? Something like:

{{#ask: [[Category:City]] [[located in::Germany]] | ?population | ?? myConstantValue }}

which would give a table like:

City Population Constant
Berlin 3,391,409 myConstantValue
Munich 1,259,677 myConstantValue
Stuttgart 595,452 myConstantValue

Why would I want to do that? Because I'd like to use a template for formatting, and I want to pass a constant string/page/number to that template as an argument, along with all the query results. The constant value might be {{PAGENAME}}, which would allow that template to know who is wanting the query results formatted. Alternatively, the constant value might be text that goes in front of each query result, allowing one page to pass in * as the constant value, and print the output as a list:

  • +1. 14:33, 18 June 2011 (CEST)
  • Berlin contains 3,391,409 people
  • Munich contains 1,259,677 people
  • Stuttgart contains 595,452 people

While another page might want to nest the output into a lower-level list by passing in ** as the constant value:

  • Germany:
    • Berlin contains 3,391,409 people
    • Munich contains 1,259,677 people
    • Stuttgart contains 595,452 people

If there isn't such a 'constant' printout statement, is there a workaround to send an extra column to a query-display template? Or is there another built-in way to accomplish this that I'm just missing?

quirkster ( 21:05, 3 November 2010 (CET))

  • +1. 14:34, 18 June 2011 (CEST)
  • Workaround: {{#ask:[[Prop::Value]]|format=ul|template=test_constant{{!}}constant=Some constant value}}. 05:32, 12 July 2011 (CEST)

Displaying All Information

Is there a way to display all the information about a query?

For example, instead of this

{{#ask: [[Category:Cities]]

is there a way to display all of the properties within a query?

Display Previous and Next Items

I have many pages that are concerts that occur. These have page names that show that date, but there are not pages for every date, only the ones that have concerts. Is there a way to display on a page links to the Previous and Next date pages that do exist, using an inline query or similar?

modify the examples

Hi everyone! I think it's possible to make this page more clear if use ask-queries as an examples or provide screenshots of Special:Ask and links to it. In this case the reader will have some idea of how to use printout statements even if she hasn't read anything else. Can I try to modify the page with this? Yury Katkov 06:16, 11 January 2012 (CET)

Yeah, I think so too. Would you start at the Russian page for me to see what you are exactly thinking about? Cheers --[[kgh]] 12:41, 11 January 2012 (CET)
Sure, I'm translating this page to Russian right now. Yury Katkov 06:09, 12 January 2012 (CET)

Show only X chars of a text value

Hi. I use Text properties, which are very long. How can I show only 100 bytes, 200, etc, instead of the entire value? Emijrp 13:44, 22 January 2012 (CET)

Good question. Nice to know if and how this may be achieved. Currently I cannot think of a solution. Perhaps you might want to try the user mailing list. Cheers --[[kgh]] 14:42, 22 January 2012 (CET)
Yaron replied this on IRC and it works: you should have the template also store a substring of the abstract using another property, using #set and #sub [1] Emijrp 01:44, 30 January 2012 (CET)
Great, I will give it a try myself and add a tip at Thanks and cheers --[[kgh]] 13:56, 30 January 2012 (CET)

Table cols width

Hi. When displaying an #ask into a table, how do I modify the width for every column? Thanks. Emijrp 15:06, 22 January 2012 (CET)

Yaron replied this on IRC: You can modify the width using CSS - add it to the page MediaWiki:Common.css Emijrp 01:46, 30 January 2012 (CET)

Missing information in the documentation

Hi, I think that the answer to the first question on this page should be in the documentation. Information that I miss in the documentation:

  1. what is and what isn't possible in displaying individual values of properties when there are more values of that property.
  2. use of the option to print a bulleted list, when the ',' works well as a separator (that is if the value itself doesn't contain any comma's).
  3. what to do when the option above doesn't work or isn't sufficient. (use subobjects instead?)

Thanks! --AdSvS 10:23, 2 April 2012 (CEST)


Thread titleRepliesLast modified
'Date' types don't seem to use/respond to "#-F" formatting203:09, 5 March 2017
sum result222:38, 9 December 2014
URL without <a>207:38, 8 December 2012
Displaying alternate pagename002:26, 10 November 2012
Displaying two property printout statements in one column?309:21, 7 November 2012
"JOIN"-ing information from multiple categories ???217:05, 18 October 2012

'Date' types don't seem to use/respond to "#-F" formatting

I'm using to host my sites, and can't seem to get the #-F formatting to have any effect. Is there a typo in the example? Here is my query:

{{#ask: [[Category:Courses]] | ?Modification date= | ?Has Liaison=Liaison | ?Has Last Editor=Last edited by | ?Is In Stage=Stage | headers=plain | sort=Modification date | order=descending | limit=300 }}

Adding "#-F [F d, y]" before the "=" in the Modification date call (or similar) has no effect.

I'd like the Modification date to be formatted differently - especially, to be able to display it in local time rather than GMT. I can do this by constructing a display template, but would rather have it done by the query itself as this page says I can!

Kirk McDermid (talk)18:16, 27 February 2017

For this to work SMW 2.4+ is required. Afaik still uses SMW 1.8.x

[[kgh]] (talk)20:48, 27 February 2017

> Adding "#-F [F d, y]" before the "=" in the Modification date call (or similar) has no effect.

{{#ask: [[Modification date::+]]
 |?Modification date#-F[F d, y]=Foo
 |?Modification date#-F[F d, y]
 |?Modification date#-F [F d, y]= Spaces are not valid!
 |sort=Modification date

Does work as described [0].

Some general suggestions when creating an issue or question.

  • Inform the audience about the version of MW/SMW you are referring to.
  • When using code or example snippets, please mark the text with <pre> or <code> to make it easier for the audience to identify or detect possible issues within the given examples.
  • Use the to create examples to help others answere your question more quickly.


MWJames (talk)03:09, 5 March 2017

sum result

The "sum" result format returns a number with spaces when is greater than 999, for example: 1 234 or 5 555 555. How can I get it plain? 1234, 5555555.

Emijrp (talk)11:47, 9 December 2014

Usually one would do it with this method but I believe the mathematical result formats do not support this. Since SMW adopted the core MediaWiki system for formatting numbers in late 2011 this can only by done using the formatnum parser function with the "R" option or via a specialised extension, e.g. NumberFormat.

[[kgh]] (talk)14:08, 9 December 2014

Yeah {{formatnum:1 234|R}} is what I was searching for. Thanks!

Emijrp (talk)22:38, 9 December 2014

URL without <a>

Edited by author.
Last edit: 07:09, 8 December 2012

How can I force {{#ask:}} to display a property of the type URL without an <a> tag, just as text? link = none and ?Has URL#- did not help.

Alex Mashintalk07:07, 7 December 2012

Heiya Alex, 1.8's new output format #nowiki like in ?Has URL#nowiki should do the trick. I just documented it for you. Cheers

[[kgh]] (talk)16:56, 7 December 2012

Thank you, it worked.

Alex Mashintalk07:38, 8 December 2012

Displaying alternate pagename

A thread, Thread:Help talk:Displaying information/Displaying alternate pagename, was moved from here to Help talk:Listwidget format. This move was made by Kghbln (talk | contribs) on 10 November 2012 at 01:26.

Displaying two property printout statements in one column?

Is there a way to display two property printout statements in one column?

For exaample:

{{#ask: [[Category:Cities]]
|?population people in ?area
Martinwiss (talk)10:25, 3 November 2012

I think it's better to use template format for that sort of things.

Yury Katkov (talk)21:30, 3 November 2012

Yes, thats true, actually I want to feed the result to the eventcalendar format. Therefore I think I can not use the template format. Maybe the only solution would be to on the page, combine the properties into another property that can contain the combined values.

Martinwiss (talk)22:00, 4 November 2012

Hmmm. I don't know much about the feeding process. Probably someone in the mailing lists knows the answer: . I would advice you to join the lists and describe your situation to the guys.

Yury Katkov (talk)09:21, 7 November 2012

"JOIN"-ing information from multiple categories ???

How is it possible to join information from several pages in an inline query?

Her is an example: Events takes place in locations. I have to categories: Events and Locations, in order to prevent data redundancy. Every event is a page with information about the event, and every location is a page with information about the location as well as it's coordinates. How can I make an inline query that lists events as well as the coordinates where they take place, although the information about the corrdinates is not shown on the event page (where you can only find information about the location-page of the event).

{{#ask: [[Category:Events]] |?Has starttime |?Has endtime |?Has location <--- of type page |?Har more information... |format=filtered }}

is it possible to combine with this...

{{#ask: [[Category:Locations]] |?Has adress |?Has contact person |?Has coordinates |?Has moore information |format=datatable }}

In SQL you would normally do this with a JOIN is there an equivalent way to join information in SMW? into something like this...

{{#ask: [[Category:Events]] JOIN [[Category:Locations]] ...ON Event.Location = Location |?Event.Has starttime |?Event.Has endtime |?Location.Has coordinates |format=filtered }}

I am sure that wont work, but I hope you understand what I want to achieve.

Take care! Martin

Has location = Location

Martinwiss (talk)16:54, 7 October 2012

Property chains with the syntax Has location.Has coordinates work in conditions, but unfortunately not in columns (and why?).

You can use template format instead, with a template containing a {{#show:}} call. Yes, the performance will be terrible.

Alex Mashintalk06:29, 8 October 2012

If the result doesn't have too many events the performance can be perfectly acceptable. I do such things with the template format all the time and I have no complaints about performance. So the performance can be terrible yes, but can also fine.

AdSvS (talk)17:05, 18 October 2012