User:Stefahn/SMW

My ever growing collection of SMW facts.

Unsolved issues
Things that fail (all of them just output all pages containing x):
 * Strange issue when I add returns within a text property. Second return is interpreted as a paragraph and table form gets broken...
 * Selecting pages: 2 queries on the same property (one with !) - (if I have  it works just fine)
 * Creating a concept with  and then using
 * Thread:Talk:Semantic Maps/Form: How to set input to mandatory?
 * Creating a concept with  and then using
 * Thread:Talk:Semantic Maps/Form: How to set input to mandatory?

Important Docs

 * Help:Selecting pages - How to get the right results
 * Help:Inline queries - How to use #ask and #show
 * Help:Configuration
 * FAQ

Upgrading
My steps to upgrade SMW: It there's an error like  run   (see this reference)
 * Extra step if there is a major update: Update the version number of SMW in : Replace   with   for example.
 * Log in via SSH / Putty.
 * Go to my /mediawiki folder.
 * Run
 * If there are any errors, run  in the /mediawiki folder and/or in the extensions/SemanticMediaWiki folder. Then run the "require" again.
 * Run.
 * Run  to rebuild the semantic data.

Official docu see Help:Installation/Using_Composer_with_MediaWiki_1.25%2B

To install SMW: (Replace "x" with the current version. Omit the bugfix release number, i.e. the third number.)
 * Run

Selecting pages
Solution: use the tilde
 * Docu: Help:Selecting pages
 * Wildcard:
 * Get pages from category WITHOUT pages from subcategories - Solution: set $smwgUseCategoryHierarchy to false in LocalSettings.php
 * 3 ways to exclude a page from an inline query (if you use this methode, make sure to create a property of type "String", not of type "Page"!)
 * It is not possible to ask for all pages of a query that are not in a specific category or concepts. For example, the query   will query every page in category "!City" instead of every page that is not in category "City".
 * Workaround to show pages from all categories except one category (German)
 * If you have a property with certain allowed values and in your ask query you have something like  you'll get an error most of the times, because you query for a value that is not allowed. For some reason all pages that have this property set, are given out as a result (which is bad).

#show

 * Syntax for #show:

Note: It's important to use "Category", not "category".
 * Print Category of current page:
 * Check if page is in a certain category (among others) and print out the result:

#ask

 * #ask doesn't work within poem tags!
 * Changing the heading for the first result column
 * Don't link property headers to their property page:
 * Link only the pages itself within results (also good to suppress that URL properties are converted to links automatically):
 * Change outputs of #ask: Use  - how to generate an customized table see here
 * Show number of results: Help:Count_format (Is there any easier way?)
 * Dealing with HTML within #ask template:


 * 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

Sorting:
 * Sorting by SMW takes into account
 * The usual ("natural") date sorting is oldest dates on top (ascending). To get the reverse (newest dates on top) I found the following way with both  and   (if you use   only, the sorting works as well, but you can't output the date since it's a number that no user understands):

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:

In your template "temp" do something like:

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.

Concepts

 * = 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

Display data
Usefull stuff for displaying data via templates:
 * Show "something" if a value is true (in German "wahr"):
 * If you updated SWM from 1.x to 2.x changes are, that commas between several values in your template disappeared. You could add  to all of your ask queries to fix that. Or, easier, you just add   to your LocalSettings.php.

Semantic Forms

 * also works for attributes of data type "text"
 * doesn't work when using . Workaround:
 * Use multiple values for the same field (for example in a property "tags")
 * Edit with form on main namespace on a German wiki: Put  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 (also for a workaround)
 * Set a property of type URL and use it as URL at the same time:
 * Doesn't work for me:
 * Workaround:
 * '''Autocomplete tricks
 * If one wants to use autocomplete without using a property add  to the form field.
 * If  doesn't work add   to the field tag.
 * '''Preloading data
 * 1st way: with  added to a button - cons: Template is not loaded if a red link is clicked for example
 * 2nd way: add  directly to free text input within the form (don't use   here because default will override existing content if editing a page) - add   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:
 * Other discussions and proposed solutions: ,
 * Parameter 
 * One can't use different tags (for example "placeholders") for the same field - see
 * One can assign different ids to a chosen value - for example . 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:

Properties

 * 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  doesn't assign the value to the property. With   it works.

Ways to define a property: German: Put Datentyp::foo_datatype on page Attribut:Foo
 * Put has type::foo_datatype on page Property:Foo
 * Use Special:CreateProperty - German: Spezial:Attribut_erstellen

German:
 * In German a property is called "Attribut"
 * in German:

Doing math on numeric property values:
 * Help:Math_related_result_formats
 * mw:Help:Extension:ParserFunctions
 * 

#set

 * = creating a silent property
 * see Help:Setting_values

Examples:

Types

 * 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  after the search for your date property - see this for more info
 * Output a date property the German way:

Search
'''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: http://www.hampshiregateway.info - Click the "Find regular club activities near your postcode" button and enter GU32 1EP in the Postcode field
 * Example2: http://www.aroundisleofwight.info - Just click on a subsection e.g. Days Out

Misc
If a = is used, one might get a red error message saying "Schwerwiegender Fehler: Der notwendige Parameter „message“ wurde nicht angegeben." unset($wgFooterIcons['poweredby']['semanticmediawiki']);
 * About the Process format: https://www.mediawiki.org/wiki/User:Hummel-riegel/SRF_Process
 * Biggest semantic MediaWikis: http://wikiapiary.com/wiki/Semantic_statistics
 * Benefits of a semantic website: http://www.youtube.com/watch?v=4rEP2YCn5WQ
 * Companies that use SMW
 * Related articles: http://wikimedia.7.n6.nabble.com/Show-related-articles-td554047.html
 * Data visualization tools: http://selection.datavisualization.ch/
 * Using  in  : use   instead of   (see )
 * Help:Querying_for_queries
 * Remove the "Powered by SMW" logo from the footer: Write the following in LocalSettings.php:
 * Pagination for pages (next page/last page): see

'''SMW and WordPress
 * Wordpress plugin to synchronize information of an Semantic Media Wiki with a WordPress blog

How to enable SMW in custom namespaces:
 * Help:Troubleshooting
 * Example: http://www.mediawiki.org/wiki/Extension_talk:Semantic_Forms/Archive_July_to_August_2012#Has_default_form.2C_based_on_namespace

SMW development
Interesting facts from Jeroen de Dauw :
 * 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

Links

 * Comparison between SMW, Cargo and Wikibase (Wikidata)
 * Wiki des Monats

German Articles about SMW:
 * http://www.linux-magazin.de/Ausgaben/2009/07/Struktur-fuers-Wiki
 * http://www.heise.de/ct/inhalt/2013/19/158/

Semantic Books:
 * Corporate Semantic Web