Join data from two pages into one table

From Semantic MediaWiki Demo Wiki
Jump to: navigation, search

Extension: Semantic MediaWiki


I found myself yesterday in a situation where I wanted to list in a table data properties scattered over two wiki pages for each row. That is, given one table row, one column was found on one page, while the other column was found on another page. After asking on #semantic-mediawiki, faceface explained me how to do this, and to write it up here. The key here is to use templates.

I had these semantic pages:

Both pages have data properties associated: SIO_000300 (yeah, don't ask) to a value, and Label on the first.

Here's the query I have on

{{#ask: [[HasPKaValue::+]]
 | ? HasPKaValue #
 |format = template
 |template = PKaValueTemplate
 |introtemplate = PKaValueTemplateHeader
 |outrotemplate = PKaValueTemplateFooter

The templates (the crucial part below) create the table. The main template part uses a #show statement to get the SIO_0003000 property from the second page: #show: {{{2}}} | ? SIO 000300. The first page is what is being queried for with #ask: [ [ HasPKaValue::+ ] ].

PKaValueTemplate look like:

 | {{{1|null}}} || {{#show: {{{2}}} | ? SIO 000300}}

PKaValueTemplateHeader look like:

{| class="wikitable sortable"
 ! Molecule !! pKa 

PKaValueTemplateFooter look like: