Domanda

How would I go about to list any duplicate values for a property in Semantic MediaWiki? A MySQL query would do fine, it doesn't have to be through a SMW query.

È stato utile?

Soluzione

I found a way that works for me:

With Extension:Variables installed, create a template {{Detect duplicates}} like this:

{{#ifeq:{{#var:a}}|{{#vardefineecho:a|{{{2|}}}}}|<!--

    Found a duplicate! Print some message:

-->Duplicate found: {{{2}}}<!--

    Not a duplicate, do nothing

-->|}}

and ask for values like this:

{{#ask:[[MyProperty::+]]
 |?MyProperty
 |sort=MyProperty
 |format=template
 |template=Detect duplicates
}}

It is important to sort the results before sending them to the template, as the duplicate has to come next to each others.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top