Help:Inverse relationships

From semantic-mediawiki.org
Jump to: navigation, search

See also the example page Germany and Help:Transitive relationships

Inverse relationships

The sample pages use Property:Located in, for example the Berlin article states the fact located in::Germany. If you want to also show this information here in the article for the object of the relationship, there are several ways to do this:

  • Special:Browse (the "eye" symbol in the factbox below) shows a page's object relationships.
  • You can query for all things located in Germany, using a query like the following. (Using the MediaWiki variables PAGENAME/FULLPAGENAME for the current pagename/pagename-with-namespace makes the query generic.)
{{#ask:
  [[Located in::{{FULLPAGENAME}}]]
  | intro=Things located in {{PAGENAME}}:_ 
  | link=all
}}

Result:

  • You could create the inverse property Location of and annotate pages with this. Semantic MediaWiki does not internally support inverse relationships, so it is up to you to keep the two properties in sync. One way to do this is to use an inline query that outputs the wiki text for the semantic annotation of the inverse property, so it would put the wiki text [[Location of::Berlin]], [[Location of::Hannover]], etc. on this page. The help documentation provides an inline query whose output you can paste in. Embedding it within a property page is complicated and requires nested templates, see California.