semantic-mediawiki

Is there a way to handle multiples of the same data property on single page?


On pages of my MediaWiki installation, I have a data property of the Record type that has a few different fields. On some pages of the wiki, I use the data property multiple times as there are different bits of information I want to be able to query from the page.

My ask query works, though it combines the fields of each instance of the property and separates them with commas. Is there a way to have each of the instances of the record property on an individual page returned as separate results?

Here is a representation of what the properties on the page look like and what they look like in the results of the query:

{{#set: Has Some Record=record1_field1; record1_field2}}

{{#set: Has Some Record=record2_field1; record2_field2}}

Output:

record1_field1, record2_field1

record1_field2, record2_field2

What I would prefer to have is:

record1_field1

record1_field2

and

record2_field1

record2_field2

Solution

  • Use subobjects:

    {{#subobject: record1 | field1=value11 | field2 = value12 }}
    {{#subobject: record2 | field1=value21 | field2 = value22 }}
    

    and

    {{#ask:
     [[-Has subobject:: Page name ]]
     |?field1
     |?field2
    }}