User:Badon/Extension:Semantic MediaWiki/Manual

Semantic MediaWiki is a system. An integrated approach is needed to make sense of how to use SMW, which itself aims to make the data in a wiki more useful. SMW documentation is scattered across several extension pages as well as many different websites, some of which are occasionally down for maintenance. This page is intended to provide supplemental information, and link all available information in one easily-accessible place.

Semantic MediaWiki
See also: Extension:Semantic MediaWiki.

Stay in the loop

 * Mailing lists
 * MWUsers forum
 * Bugzilla, All SMW-related bugs

TODO
If you want to do any of these things, contact badon. It might be possible to arrange some donated funding for you.


 * Add jqPlot and PHPlot to Semantic Result Formats for enhanced data visualization.
 * Create Extension:ImageAnnotator to ease installation of ImageAnnotator. Currently installation must be done manually, and all scripts, templates, messages, etc are tuned for only WikiMedia Foundation wikis. An extension can make it simple to install on any wiki. You may view changes done to make it work on a private MediaWiki installation here:
 * Create Extension:Semantic_ImageAnnotator to enable Semantic Forms in ImageAnnotator, so image annotations can be part of SMW's semantics.
 * Extension:Collection needs to support parser functions and work with SMW's property syntax

Shortcomings and limitations

 * Cannot traverse property "chains" easily with ordinary queries.
 * "Lite" version for Wikipedia will not be able to do queries at all.
 * Semantic forms cannot create file pages
 * SMW persistently shows deleted pages

Common problems

 * If you use a query with the sort parameter for a property, if there are any pages that do not have that property, they will not be returned in the query. You might normally expect them to be returned unsorted.

Needed special properties

 * Page name
 * Page categories
 * Page templates
 * Page forms
 * Page number of edits
 * Page number of links outbound
 * Page number of links inbound
 * Page size
 * Page number of views
 * Page modification date - already implemented
 * Page creation date - in progress
 * Page creator 30610
 * Page editors 30610
 * Page last editor
 * User registration date
 * User number of edits

Of those in the above list, these are currently doable, mostly with workarounds, and should have lower priority:


 * Page name - store manually with magic word
 * Page categories - store manually, also queriable as ?Category
 * Page templates - store manually
 * Page forms - store manually
 * Page modification date - already implemented

These are available in Extension:SemanticExtraSpecialProperties30610:


 * Page creator
 * Page editor
 * Revision ID
 * Number of page views

This list of needed special properties is taken from these three sources:


 * http://smw.referata.com/wiki/Add_page_metadata_properties_to_a_page_(using_DPL)
 * 13151
 * 29988 (mentions they need need to show in SMW factbox)

And consolidated here:


 * 30610

Page creation date has turned out to be critical:


 * 30784

Additionally, special properties do not show up in the SMW factbox:

30628

Future goals

 * Extension:Page_Schemas
 * SMW roadmap
 * To do list

How to

 * SMW tips
 * User:Badon/Extension:Semantic MediaWiki/Manual/Using templates to custom format a table query
 * User:Badon/Extension:Semantic MediaWiki/Manual/Using templates to custom format multiple queries in a single table
 * User:Badon/Extension:Semantic MediaWiki/Manual/Properties should point from child to parent
 * User:Badon/Extension:Semantic MediaWiki/Manual/Introduction to queries of interconnected properties
 * User:Badon/Extension:Semantic MediaWiki/Manual/Querying forward from child to parent through a property chain
 * User:Badon/Extension:Semantic MediaWiki/Manual/Querying backward from parent to child through a property chain
 * User:Badon/Extension:Semantic MediaWiki/Manual/Run a query only once
 * User:Badon/Extension:Semantic MediaWiki/Manual/Semantic naming best practices

Semantic MediaWiki 1.7 undocumented breaking changes
The official Semantic MediaWiki documentation is obsolete. In fact, the official SMW site is still running an obsolete version of SMW. Documented below are some crucial differences that upgraders will need in moving from SMW 1.6.x to SMW 1.7.x.

#ask query for page names
If you upgraded to Semantic MediaWiki 1.7 and suddenly nothing works on your site, it is because there were undocumented breaking changes made to the #ask query syntax. In earlier versions, this used to produce page names:

Now it produces a table with the page names repeated such that there are two columns containing the same page name data, that looks like this:

These queries now produce the same output, identical to the older behavior of SMW prior to 1.7 that would be expected from the first example where only the page names were output:

I'm still not sure if that intentional, or is a bug, but I think it is intentional. The new behavior seems reasonable, and simpler, even though it's a frustrating breaking change that is undocumented, not backwards compatible, and requires site-wide changes to fix broken queries. If this was intentional, it should definitely be documented very prominently so users will know in advance that upgrading will break older queries, and explain what they need to change to fix the broken queries so they will display as intended with SMW 1.7.

count format
This used to produce 0 if there were no results:

Now, it produces nothing instead of zero. You can get a zero this way (using Extension:Variables for #vardefine):

Then, you have a variable that contains the number 0 if your query has no results. The reason you use #vardefine is so you only need to run the query once. Without it, you may need to run it multiple times, every time you want to use the number of results.

However, when your query is on a property, it will still give you 0 like it always has, even if the property does not exist on your wiki:

This is inconsistent behavior, and is probably a bug, described here: count format not producing 0 on non-existing category queries.

#ask multiple property comma delimited list format
This used to produce a comma delimited list of values if a property was specified more than once, so that it has more than one value:

Some property::value 1 Some property::value 2

The output would look like this:

value 1, value 2

Now it produces a table with the multiple properties listed in a column, like this:

These queries now produce the same output as they did with the older versions of SMW:

The output will look like this:

value 1, value 2

Note that there is a serious bug that inserts 2 invisible spaces after the comma, instead of just one that you will see in your web browser when you run the queries above on a wiki that has SMW installed. The extra space is invisible because web browsers do not display more than one space at a time - all other spaces are hidden. If you try to do comparison operations, you will get incorrect results. The bug is described in detail here:

33478

Semantic Forms
See also: Extension:Semantic Forms and Extension:Semantic Forms/Manual.


 * Extension:Semantic Forms/Version history
 * Extension:Semantic Forms/Code structure
 * Extension:Semantic Forms/Example
 * Extension:Semantic Forms/MediaWiki red links code change
 * Extension:Semantic Forms/Defining new inputs


 * Extension:Semantic Forms/Manual/The forminput parser function
 * Extension:Semantic Forms/Manual/The formlink parser function
 * Extension:Semantic Forms/Manual/Special:AddData
 * Extension:Semantic Forms/Manual/Preloading data

How to

 * User:Badon/Extension:Semantic Forms/Manual/Using Semantic Forms for file pages and uploads
 * Extension:Semantic Forms/Manual/Display or hide fields depending on user selections
 * Extension:Semantic Forms/Manual/Hide the Edit with form tab for non logged-in users
 * User:Badon/Extension:Semantic Forms/Manual/Check for previous existence to ensure uniqueness of a submitted property
 * User:Badon/Extension:Semantic Forms/Manual/Conditional branching of forms
 * User:Badon/Extension:Semantic Forms/Manual/Multiple values for the same field

Shortcomings and limitations
See also: Extension:Semantic Forms/Known bugs and planned features


 * #formlink parses query strings incorrectly if there is an & character in parameters

Shortcomings and limitations

 * Display_points fails in templatized queries with unnamed parameters because points are delimited by semicolons, but Semantic Maps cannot handle a semicolon on the last point. This can be worked-around with more complex conditional code to find the last point, and ensure it does not have a semicolon. See 30534
 * Maps do not work in most situations when a map is generated within a template. A workaround is available for 1.0.1. Version 1.0.4 of the Semantic Maps bundle cause a wiki to completely cease functioning, and 1.0.3 causes the workaround used in 1.0.1 to fail. 1.0.2 has not been tested. 32416