FANDOM


This is a compilation of some SMW and Semantic forms tips and tricks learned by Wikia contributors.

Introductory tipsEdit

  • The type "Page" may appear useless because values returned from queries cannot be manipulated in templates because they have square brackets around them. To get the plain text values, add the operand "|link=none " to the query.

Advanced tipsEdit

Values returned from #Ask queries can have hidden textEdit

Problem you will see: #ifeq or #eval and other wikitext functions behave in unexpected ways with results from #ask or #show expressions. For instance, if you display the value returned from #ask, you see "foo", yet expressions like {{#ifeq:<ask expression returning foo>|foo|true|false}} return false.
Verify you have this problem. Do a #len on the string. If this phenomenon is the culprit, you will see a wildly higher number than expected. Instead of the expected "3" for foo, you will see something like 24.
Explanation: SMW is inserting hidden text into the returned values. This may be stripped by a #replace operation.
Fix: {{#replace:{{#replace:<#ask or #show expression here>|[[SMW::off]]|}}|[[SMW::on]]|}}

The same parameter is repeated in every template fed by a semantic formEdit

Problem you will see: A semantic form with more than one "for template" is used to add data to an article. After editing the article modified by the form, there will be newly inserted parameter values inserted for all templates mentioned in the form.
Explanation: This is caused by mismatching between the form and the templates. By searching on the parameter value in the form and in the templates, you will either see that the there are no templates recieving the parameter, or that one of the templates is expecting a value that has not been set on the form.
Fix: Correct the mismatch by either adding or subtracting the parameters from either the form or templates, so that they are in agreement.

Parameters may be passed to template handlers for queriesEdit

For instance the following syntax will pass the value bar to Template "birthDisplay"'s parameter foo:

{{#show:Abraham Hunsberger (1786-1860)|template=birthDisplay{{!}}foo=bar|?birth locality}}

Type:code properties make wide windowEdit

Properties of type code can be used to store wikitext, however if the facts box is not hidden, these fields can create unusually wide windows forcing the browser to put up a horizontal scroll bar.

Fix:

To Mediawiki:monaco.css add the following:

/* Set SMW type Code property windows in the SMW factbox so that it doesn't extend past the window size.  Also set word wrap 
for browsers that recognize it (IE, and soon firefox) - Phlox */
.smwpre {
    width:800px;
    white-space:-moz-pre-wrap; 
    white-space:-pre-wrap; 
    white-space:-o-pre-wrap; 
    white-space:pre-wrap; 
    word-wrap:break-word;
}

Comma delimiter in multi valued property Edit

Background: You have a property of type page that holds multiple values. In a query, your #ask sends the output to a template. For the multi valued property, you can parse each value out fine with arraymap using the comma as a delimiter.

However, when pages are stored in the multivalued property that themselves have a comma in them (eg. Greene county, Ohio), then the arraymap messes up.

Fix: Do a #replace on ]], with ]]; For example:
  {{#arraymap:{{#replace:{{{1|}}}|]],|]];}} |;|blah blah blah

Replace semicolon with whatever other safe delimiter you want.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.