SMW InlineQueryParserFunction Extension


Jump to: navigation, search

Important! This code targets SMW version 0.6 and is known not to work with 0.7. Also, the latest Semantic MediaWiki code already has an {{#ask}} function - which is of course, fantastic news!

The SMW_InlineQueryParserFunction Extension is a MediaWiki extension which adds a parser function {{#ask}} which complements the Semantic MediaWiki extension tag <ask>.

It is tentatively released under The MIT License.



This extension requires:

  • MediaWiki 1.10.x or higher
  • Semantic MediaWiki 0.6
  • PHP 5.x or higher


  1. Download SMW_InlineQueryParserFunction, and be sure to rename the downloaded file to SMW_InlineQueryParserFunction.php.
  2. Drop this script in $IP/extensions
    Note: $IP is your MediaWiki install dir.
  3. Enable the extension by adding this line to your LocalSettings.php:
    Note: Make sure this appears later in LocalSettings than the include_once() call which enables Semantic MediaWiki itself!


Once installed, you (or editors of your wiki) may perform Semantic inline queries in parser function form.


To query for an unordered list of results in extension tag form, you might do this:

<ask format="ul">[[some relation to::Some Page]]</ask>

The equivalent parser function form is this:

{{#ask:format=ul|[[some relation to::Some Page]]}}
{{#ask:[[some relation to::Some Page]]|format=ul}}

If the text of the query would contain an '=' sign, then the text portion should be prepended with 'query='.

For example, this extension tag query:

<ask format="ol">
  [[located in::Africa]] 

Would fail due to the '=' sign in the Population clause if it were to be specified like this:

  [[located in::Africa]] 

However, it should work just fine if specified like this:

  [[located in::Africa]] 

Technical Details

A sizable chunk of the Semantic MediaWiki code surrounding the processing of Inline Queries was duplicated to create this extension to avoid modifying the SMW core.

Ideally, these changes would be integrated directly into a future release of the extension since they're passive regarding existing functionality.


Leave a comment
Sorry, comments are disabled.

or, read what others have said ...