Search code examples
semantic-mediawiki

Can I use a property's value as a query in semantic-mediawiki?


I am attempting to query for a list of pages specified via a template variable, but I cannot get my head around Semantic Mediawiki well enough to even identify if this is possible, let alone a good idea.

I have a set of pages which have semantic properties. I then have a template which has a "collection" variable which is just a list of pages as follows:

// Bucket template
{{#set:
 | Has fishes={{{fishes|none}}}|+sep=,
}}

// A bucket page
{{Bucket
 |fishes=Fish Page, Another Fish Page, Trout Page
}}

So far so good.

Now, I want to create a table in the Bucket template which displays some properties from the listed pages. If I try using a #show as follows:

{{#show:{{PAGENAME}}|?Has fishes
 |format=table
 |?Has fishName= name
 |?Has fishHeight = height
}}

I can't get anything other than the links to the pages. I can't actually query properties of those pages. My question is:

How do I feed the pages I already have in the current pages Has fishes property to an #ask? I don't know what to ask for, since I already have the answer, but I don't seem to be able to format the answer correctly without asking for it. I've tried a few {{PAGENAME}}: variations, but that's just been stabbing in the dark.

{{#ask:
 [[---what goes here and why?---]]
 |?Has fishName= name
 |?Has fishHeight= height
}}

Solution

  • Semantic Media Wiki supplies as Sandbox which is good for experimenting.

    I have added pages according to your question as the Fish Category.

    Please note that the Sandbox's default language is french. In an English wiki the pages would have different names.

    For your idea to work you are looking into how to create a tabular list based on a comma separated list of values. You do not actually have to query for that list since in the template the parameter "fishes" already has the list of values.

    You might end up having to use the Template Format for your query.

    The Example that shows different style of showing a table of images shows the different approaches. A standard approach is:

    1. show the header of a table
    2. query for each row
    3. show the footer of the table

    For querying each row you have the options:

    1. to use the array extension which is installed in the sandbox wiki https://www.mediawiki.org/wiki/Extension:Arrays There might be a loop functionality available.
    2. to use subobjects