Semantic MediaWiki can provide links to online services when printing certain data in the factbox. For example, when a geographic coordinate is entered into an article, it is useful to provide links to online mapping services, so that users can retrieve a map of the specified area with one click. This page explains how you can add such features to a semantic wiki (without writing PHP code to support a new datatype).

The information for additional links to online services in the factbox is associated with the property used. For example, on ontoworld.org ow:Property:Coordinates will show various links to online maps when it appears in the factbox, whereas other properties that also use Type:Geographic coordinate might not show this. This is crucial in many applications, since the datatype alone usually does not say much about the type of link. For example a property "IMDb number" might be used for a movie's id number at IMDb, but not every property of Type:Number should display a link to IMDb.

In order to attach some services to a property, use the special property provides service on its page. For example, the article Property:Coordinates might include the annotation

[[provides service::online maps]]

Here, "online maps" is the name of a set of service links provided by the wiki. The next section explains how you specify these services.

The text specifying the appearance of service links goes in a special message article in the "MediaWiki" namespace named MediaWiki:Smw service service name.
In the same example as above on ontoworld.org, the text for [[provides service::online maps]]
is in ow:MediaWiki:Smw service online maps.

Normally only users that have sysop (administrator) privileges in the wiki can add or edit pages in the MediaWiki namespace, hence only they can modify service links.
This is a reasonable restriction for most wikis: since service links may appear in thousands of factboxes, they need to be trusted.

All users, however, are free to use or not available services in properties as described above. In any case, adding or modifying services should usually be discussed among many users before an admin is asked to put the change into practice.

When adding a service with the special property "provides service", the factbox of the given article will display a link that is labeled like the given service. For example, the factbox of the above property "Coordinates" would display the link "online maps." Following this link leads you to a message article, in this case MediaWiki:Smw service online maps, that lists the links that are provided by this service. Though the message might be hard to read due to the long lines, its format essentially is as follows:

label|http://someurl.org
label2|http://anotherurl.org
...

Every line contains one link that should be shown in the factbox. The label is the text that users will see in the factbox (e.g. "IMDB" if ou link to this service). After the "|" it is followed by a URL that the link will lead to. In most cases, the URL will need to contain certain information about the property value for which the service eventually is provided. For example, a link to an online map surely must include the coordinates that the map will show, and a link to IMDb will have to include the ID of the movie that is referred to.

Since the exact data values are not known in advance, the URLs in the above messages only contain place holders of the form $1, $2, $3, … For example, a link to IMDb could look as follows:

IMDb|http://www.imdb.com/title/tt$1/

The placeholder "$1" indicates the position that the property should later insert its value into in order to create the actual link in the factbox. The number and contents of the parameters depends on the property that uses the service, and especially on its datatype. For instance, a simple integer property might merely replace $1 by its value, whereas a geographic coordinate provides much more parameters for latitude, longitude, direction, and much more. In most cases, $1 will be the most relevant parameter that just provides a URL-save string version of the property value.

Since service links are typically perceived as "trusted resources," administrators must take some care when formulating links, keeping in mind that users might insert almost arbitrary URL-encoded strings for the place holders.

To illustrate the whole process of creating and using a new service, we provide an extended example, also implemented on ontoworld.org. Articles about Semantic Web vocabularies such as ow:FOAF contain information about the vocabulary's "namespace" and the online service ow:Swoogle allows users to search for background information on such namespaces. Our goal thus is to add a new "Swoogle service" to the ow:Property:Namespace that is used on the vocabularies articles.

The link was retrieved by using Swoogle and replacing the search string (at the end of the link) with the parameter "$1".

After those changes are saved, the new service is fully functional, and each page that uses ow:Property:Namespace will show a suitable link to Swoogle. Some articles will still show the old version, if they are retrieved from cache, but after the next edit or purge, all articles will display the links as expected.