Jump to: navigation, search

My ever growing collection of SMW facts.

Unsolved issues

Important Docs

Selecting pages


  • Syntax for #show:
  • Print Category of current page: {{#show: {{FULLPAGENAME}} | ?Category }}
    Note: It's important to use "Category", not "category".
  • Check if page is in a certain category (among others) and print out the result: {{#ifeq:{{#pos:{{#show: {{FULLPAGENAME}} | ?Category }}|Category_To_Check}}| |Output for "not in this category"|Output for "in this category"}}


  • #ask doesn't work within poem tags!
  • Changing the heading for the first result column |mainlabel=heading
  • Don't link property headers to their property page: |headers=plain
  • Link only the pages itself within results (also good to suppress that URL properties are converted to links automatically): |link=subject
  • Change outputs of #ask: Use |format=template - how to generate an customized table see here
  • Show number of results: Help:Count_format (Is there any easier way?)
  • Sorting by SMW takes into account {{DEFAULTSORT:Your_Sort_Stuff}}
  • Dealing with HTML within #ask template: [1]


  • all available formats see Help:Result formats
  • If omitted, all queries are displayed as tables (format table), unless there would be only one column, in which case the results are displayed as a comma-separated list (format list).
  • Help:Feed_format

URLs length issue

URLs can only take up to 255 characters (see this bug report).

To find out which of your URLs get truncated you can do the following:

{{#ask: [[YourURLProperty::+]]
| format=ul
| template=temp
| limit=2000

In your template "temp" do something like:

{{{1}}} {{#len:{{{2}}}}}

Note that the length returned is two times the real URL length plus 3 characters (I assume that's from the format [URL URL]). So you have to check your list for values of 513 (= 2*255 + 3) and shorten those links with an URL shortener.


  • = dynamic categories
  • useful to create "categories" like "People, born in 1982, born in Germany" for example
  • big advantage: Pages don't need to be adapted, one just has to change/create the concept

Semantic Forms

  • input type=dropdown also works for attributes of data type "text"
  • default=now doesn't work when using input type=year. Workaround: default=2016
  • Use multiple values for the same field (for example in a property "tags")
  • Edit with form on main namespace on a German wiki: Put [[Hat Standardformular::Foo]] on the page Wiki_Name:Startseite - see discussion here
  • If the allowed values of a property are not shown in alphabetical order in a dropdown: Copy the content of the property page, blank the property page, then paste the content again.
  • One can't change the page name within a form - see [2] (also for a workaround)
  • Set a property of type URL and use it as URL at the same time:
    • Doesn't work for me: [[[Property::{{{Field|}}}]] Anchor text]
    • Workaround: {{#set:Property={{{Field|}}}}} [{{{Field|}}} Anchor text]
  • Autocomplete tricks
    • If one wants to use autocomplete without using a property add |input type=text with autocomplete to the form field.
    • If values from namespace= doesn't work add |property=Foo to the field tag.
  • Preloading data
    • 1st way: with |query string=preload=Template:foo added to a button - cons: Template is not loaded if a red link is clicked for example
    • 2nd way: add preload directly to free text input within the form (don't use default here because default will override existing content if editing a page) - add default to other fields (for example to category input - in this case default doesn't override existing categories)
  • Deal with existing pages
    • Basically one can use #forminput and do autocomplete on category or namespace (unfortunately autocomplete on property is not possible)
    • My discussion with Yaron regarding my URL problem: [3]
    • Other discussions and proposed solutions: [4], [5]
  • Parameter show on select
    • One can't use different tags (for example "placeholders") for the same field - see [6]
    • One can assign different ids to a chosen value - for example Same-Value=>id_one;Same-Value=>id_two;. This is very helpful since it's not possible to use the same id twice.
    • One can do nested divs.
    • It seems impossible to use the generated div ids directly in table rows - use a separate table instead like:
<div id="fooid">
{| class="formtable"
! Bla
| {{{field|blupp}}}


  • SMW has some useful built-in properties: see Help:Special_properties
  • If no value is provided (in a form), the corresponding property is not defined for that page.
  • Parser functions: I found that {#if: [[Property::{{{Value|}}}]] | {{{Value|}}} | some text }} doesn't assign the value to the property. With {#if: {{{Value|}}} | [[Property::{{{Value|}}}]] | some text }} it works.

Ways to define a property:


  • In German a property is called "Attribut"
  • [[Allows value::foo]] in German: [[Erlaubt Wert::foo]]

Doing math on numeric property values:



{{#set:Has population=3,396,990|Has country=Germany}}


  • Since SMW 1.8.0 datatype "String" (German: Zeichenkette) was deprecated and replaced by datatype "Text"
  • If your wiki doesn't run in English and you have issues changing dates with the parser function #time, then add #ISO after the search for your date property - see this for more info
  • Output a date property the German way: {{#time:d.m.Y|{{{1}}}}}


Semantic Drilldown

  • Faceted search without fulltext search support.
  • + Very nice setup interface and very flexible extension.
  • - Incomprehensible appearance by default: you will have to write your own CSS to make it clear.
  • - can be slow on the big amount of properties

Filtered result format

  • Good for visualizing the queries (<1K-2K pages Yury Katkov guesses).
  • Nice setup of facets, allow search by property values.
  • Doesn't provide full text search by pages

Filtered format of the Semantic Results Format extension.

  • Neill Mitchell often couples it with a Semantic Forms runQuery to provide search capabilities with property filters.
  • Example: - Click the "Find regular club activities near your postcode" button and enter GU32 1EP in the Postcode field
  • Example2: - Just click on a subsection e.g. Days Out




SMW development

Interesting facts from Jeroen de Dauw [2]:

  • In 2013 20 developers contributed to SMW Core (total: 68 developers) -> SMW is in the top 10 % in the world regarding contributers to Open Source projects - The vast majority of Open Source projects have only 1 contributor
  • SMW maintainers: Markus Krötzsch, James Hong Kong, Jeroen de Dauw
  • ~1000 commits during 2013
  • Tool to test new code: Jenkins, Travis CI


German Articles about SMW:

Semantic Books: