Tagging Semantic Articles Outside of the Factbox

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. 1

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.

Screen Shot 2014-12-17 at 1.19.10 PM

 

Along the right hand column of every article are the tags for the audience and topic areas related to the article.

linked-list

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 2 to format the comma separated list of values. 3

'''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 4 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.

SearchByProperty

The result is that every topic area listed on the page becomes a link to Special:SearchByProperty that shows all pages with that value.

Screen Shot 2014-12-17 at 5.02.52 PM

When editors add a new article they only have to add a list of topic areas. 5 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.

Footnotes

  1. I’m sharing this not only in hope of helping others, but to learn how to improve my own use of SMW. Leave a comment if you have a better way.
  2. Provided by the indispensable Semantic Forms extension.
  3. You’ll also want to have an arraymap to store the property/value pair somewhere in your template. I keep mine hidden at the bottom of the template with a div set to display:none; and something like {{#arraymap:{{{Facets Article Topic Areas|}}}|,|@@|[[Facets Article Topic Areas::@@]]}}
  4. Yes, I need to use better template names!
  5. Made incredibly easy with the new ‘token’ input in Semantic Forms.