Discuss Displaying information

From semantic-mediawiki.org

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 Semantic MediaWiki user mailing list is always a good idea for seeking help.

Displaying nested properpies on the same query[edit]

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!

Question[edit]

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.

68.224.44.77 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?[edit]

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. 178.72.112.204 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 (76.76.146.52 21:05, 3 November 2010 (CET))

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

Displaying All Information[edit]

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

For example, instead of this

{{#ask: [[Category:Cities]]
|?population
|?area
|?coordinates
}}

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


Display Previous and Next Items[edit]

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[edit]

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[edit]

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 smw.referata.com. Thanks and cheers --[[kgh]] 13:56, 30 January 2012 (CET)

Table cols width[edit]

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[edit]

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! --Ad Strack van Schijndel 10:23, 2 April 2012 (CEST)

Contents

Thread titleRepliesLast modified
Add missing information to set image size011:49, 8 November 2019
How to avoid following redirects?205:47, 12 September 2018
'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 ???216:05, 18 October 2012

Add missing information to set image size

11:35, 8 November 2019

How to avoid following redirects?

It would be nice to have on this help page an example of how to keep redirecting page name if the property of type Page links to a redirection page.

To be verbose and more specific:

1) Let us define "Full name" and "Short name" as a properties of type Page

2) on some page in category 'Names' put the text:

The full name of [[Short name::Bart]] is [[Full name::Bartolomeo]]. 

3) create page 'Bartolomeo' with some information about the name.

4) put redirection to 'Bart' page

#redirect[[Bartolomeo]]

5) make request

{{#ask: [[Category: Names]]
 |?Short name

6) we get 'Bartolomeo' page as a result, but how to keep it 'Bart'?

Several hours of digging the SMW site did not give me a result. Bad luck or lack of information? 24pm (talk) 05:51, 7 September 2018 (CEST)

04:51, 7 September 2018

This is expected behavior if property "Short name" is of datatype "Page". Sometimes the solution is easier than one may think. Switch this property to datatype "Text" and you will get the desired result. I recommend to also set up examples on the sandbox to make it easier to fiddle.

15:59, 7 September 2018

Indeed! Simple and helpful. Thank you!

05:47, 12 September 2018
 
 

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

I'm using referata.com 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!

18:16, 27 February 2017

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

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!
 |headers=plain
 |sort=Modification date
 |order=descending
 |limit=3
}}

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 https://sandbox.semantic-mediawiki.org to create examples to help others answere your question more quickly.

[0] https://sandbox.semantic-mediawiki.org/wiki/ModificationDateFreeFormat

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.

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.

14:08, 9 December 2014

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

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.

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

16:56, 7 December 2012

Thank you, it worked.

07: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
|format=table
}}
10:25, 3 November 2012

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

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.

22:00, 4 November 2012

Hmmm. I don't know much about the feeding process. Probably someone in the mailing lists knows the answer: https://lists.sourceforge.net/lists/listinfo/semediawiki-user . I would advice you to join the lists and describe your situation to the guys.

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

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

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

16:05, 18 October 2012