Help talk:Count format

From semantic-mediawiki.org

Contents

Thread titleRepliesLast modified
Using format=count together with intro/outro116:07, 11 January 2019
Bad number of pages count in a category518:48, 4 December 2018

Using format=count together with intro/outro

Just picked up the example from bugzilla using the intro and outro parameter.

{{#ask: [[Property::Value]] 
|format = count
|intro  = Found:   
|outro  =  results:
}}
  is used as space character

null parameter[edit]

What do you think about adding some kind of null parameter to count? The ide is that if nothing is found (count=0) the text in the null parameter will be used. It can be helpful in the following scenarios: 1. We want to make count pretty and add some special text in case nothing is found.

{{#ask:[[Category:Scientist]]
|format=count
|null= No one
|outro=found}}

In fact in those cases several parameter would be useful: for 0 and 1 counts.

pre>0found

2. We want to use count in {{#if function}}: in that case it will be null=

Yury Katkov (talk) 04:03, 5 August 2012 (CEST)

18:47, 4 December 2018

Just in case ...

Available work-around(s):

{{#ifeq:
  {{#ask: [[Property::Value]] | format = count }} | 0 
  | case: Is Zero (just add Zero case pretty print here) 
  | case: Is Not Zero (enclose same #ask-count-code together with additional pretty print)
}}

Or alternatively:

{{#if:
  {{#ask: [[Property::Value]] }}
  | case: Data found == none zero-count (enclose #ask-count-code together with additional pretty print)
  | case: No data found == zero-count (just add Zero case pretty print here) 
}}

_#switch also comes to mind ... but did not checked/tested that one.

If needed one could create a template to take care of the default stuff. So one could use something like this.

{{count_pretty_print
| <#ask-count-call> ... or perhaps just the property input data (speculative/untested).
| <zero pretty print text>
| <None-zero leading pretty print text>
| <None-zero trailing pretty print text>
}}
16:06, 11 January 2019
 

Bad number of pages count in a category

Hello,

I'm trying to get the actual number of pages which are in a category with following query :

{{#ask: [[Category:a category]] |format=count}}

Unfortunately, the results includes redirected pages and thus is superior to the right result expected.

How can I exclude redirected pages from this query ?

Thanks,

Nicolas NALLET (Sémantiki)

14:57, 8 December 2015

It seems to work here [0] (unless I have misunderstand the issue).

[0] http://sandbox.semantic-mediawiki.org/wiki/CountExample

15:22, 8 December 2015
 

I have also seen it on one particular query, [0] suggests a patch and it would be great if you could apply/test/verify this before we make an effort to push this into the master branch.

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/1301

06:26, 9 December 2015

Ok thanks MWJames, I'm trying this patch soon and tell you if it's working.

Nicolas NALLET (Sémantiki)

10:54, 11 December 2015

Sorry for the late reply. Unfortunately the patch did'nt fix the problem. I will test with SMW 2.4 when available.

Thanks

Nicolas NALLET (Sémantiki)

10:37, 8 March 2016

Is this still an issue?

18:48, 4 December 2018