Search code examples
semantic-mediawiki

Listing pages having only one value for multi-value property


I am working on wiki where every item has its own page and its means of acquiring it listed as

[[Is acquired::somewhere]]
[[Is acquired::somewhere else]]
[[Is acquired::some third acquisition way, really long one with some [[wiki]] links in it]]

The property Is acquired has defined type text.

My primary question is: How can I show a list of those items having assigned only one way to acquire them (ie. one Is acquired property-value)?

Secondary is: How to list those items, that have only one way to acquire them and this way contains some specific text?

I have read Extension:Arrays and also Count format and Subqueries documentation, but I just can not figure it out how to put everything together.

Please note that preferably, I would like to avoid using Extension:Arrays, if it's at all possible, as this is currently not supported by wiki I am working on.


Solution

  • I believe there is no way in SMW to filter on number of property values, so you should use Extension:Arrays here.

    Introduce new property which will be used as flag, eg. Is only one way with values Yes/No. On your pages (containing Is acquired properties) add code like this at bottom:

    {{#arraydefine:test_arr|{{#show: {{PAGENAME}}|?Is acquired}}|,}}
    {{#ifeq:{{#arraysize:test_arr}}|1|[[Is only one way::Yes]]|[[Is only one way::NO]]}}
    

    This way all your pages will contain a property Is only one way with values Yes or No so you can filter on it:

    {{#ask: [[Is acquired::+]] [[Is only one way::Yes]] }}
    

    Will give you pages with only one value set for Is acquired property.