One of my favorite Semantic MediaWiki features is the factbox. It’s a quick way to browse wiki content by property values.
What if you want a similar browsing interface within a wiki page? For example, let’s say you want a value for a property you use to ‘tag’ an article to provide a link to a list of all pages with that property/value pair. Here’s one way how.
For the past year one of the ways we’ve been using our wiki is to publish an internal monthly newsletter. Each newsletter article is a wiki page, with a template providing consistent navigation.
Along the right hand column of every article are the tags for the audience and topic areas related to the article.
Recently I made an addition to the list of Audience and Topic Area tags to provide dynamic links to all pages with that property value. I’m leveraging the SMW Special:SearchByPropertySpace special page.
In the article template, with the property “Facets Article Topic Areas” you’ll want to use an arraymaptemplate to format the comma separated list of values.
'''Topic Areas''': {{#arraymaptemplate:{{{Facets Article Topic Areas|}}}|SearchByPropertySpace-FacetsArticleTopicAreas|,|, }}
What this will do is take every value for the property Facets Article Topic Areas and use the SearchByPropertySpace-FacetsArticleTopicAreas template to format each value. Each value is separated by comma, and our final output will be separated by a comma and a space.
In the template “SearchByPropertySpace-FacetsTopicAreas” we have the following.
[[Special:SearchByProperty/Facets-20Article-20Topic-20Areas/{{#replace:{{{1}}}| |-20}}|{{{1}}}]]
This creates a link to Special:SearchByProperty where the property name is Facets Article Topic Areas and the value is each comma separated value from our arraymaptemplate.
The replace parser function converts values with spaces to URL encoded characters.
The result is that every topic area listed on the page becomes a link to Special:SearchByProperty that shows all pages with that value.
When editors add a new article they only have to add a list of topic areas. This makes in-article links to all other articles a click away without having to scroll to the bottom of the page to view the factbox.