Changes

MyWikiBiz, Author Your Legacy — Saturday May 04, 2024
Jump to navigationJump to search
Line 5: Line 5:  
</blockquote>
 
</blockquote>
   −
[[http://semantic-mediawiki.org/wiki/Semantic_MediaWiki Semantic MediaWiki] includes a simple query language for [http://semantic-mediawiki.org/wiki/Help:Semantic_search semantic search], so that users can directly request certain information from the wiki. Readers who do not wish to learn the query syntax can still profit from this feature: '''inline queries''' dynamically include query results into pages. So queries created by a few editors can be consumed by many readers.  
+
[http://semantic-mediawiki.org/wiki/Semantic_MediaWiki Semantic MediaWiki] includes a simple query language for [http://semantic-mediawiki.org/wiki/Help:Semantic_search semantic search], so that users can directly request certain information from the wiki. Readers who do not wish to learn the query syntax can still profit from this feature: '''inline queries''' dynamically include query results into pages. So queries created by a few editors can be consumed by many readers.  
   −
Inline queries are similar to other semantic search features, and can also be restricted on a site in order to ensure sufficient performance. Since inline queries exploit the existing caching mechanisms of [http://mediawiki.org/wiki/MediaWiki | MediaWiki]], most requests for a page with such dynamic contents can be served without any performance impact whatsoever.
+
Inline queries are similar to other semantic search features, and can also be restricted on a site in order to ensure sufficient performance. Since inline queries exploit the existing caching mechanisms of [http://mediawiki.org/wiki/MediaWiki | MediaWiki], most requests for a page with such dynamic contents can be served without any performance impact whatsoever.
    
== Introduction to #ask ==
 
== Introduction to #ask ==
Line 26: Line 26:  
}}
 
}}
   −
It is common to put the query as the first parameter behind <tt>#ask:</tt>. All other parameters are separated by <tt>|</tt>, just like for other [[meta:Help:Parser_function|parser functions]]. The exact formatting of the inline query is not essential, but it is good to use line breaks to make it more readable to other editors. As with all templates, one line per parameter, starting with the <tt>|</tt> is most accepted in practice.
+
It is common to put the query as the first parameter behind <tt>#ask:</tt>. All other parameters are separated by <tt>|</tt>, just like for other [http://semantic-mediawiki.org/wiki/meta:Help:Parser_function parser functions]. The exact formatting of the inline query is not essential, but it is good to use line breaks to make it more readable to other editors. As with all templates, one line per parameter, starting with the <tt>|</tt> is most accepted in practice.
    
Note that all the arguments to the #ask: function are ignored by the page parsing, hence the above example does not add a category or a «located in» property annotation to this page. A few more things to note are:
 
Note that all the arguments to the #ask: function are ignored by the page parsing, hence the above example does not add a category or a «located in» property annotation to this page. A few more things to note are:
Line 34: Line 34:  
* The format of the results display changes when you request display of additional properties.  SMW picks an appropriate default format for query results, but you also have detailed control of the appearance of query results.
 
* The format of the results display changes when you request display of additional properties.  SMW picks an appropriate default format for query results, but you also have detailed control of the appearance of query results.
   −
Knowing the basics of [http://semantic-mediawiki.org/wiki/Help:Selecting_pages query string] and [http://semantic-mediawiki.org/wiki/Help:Displaying_information printout statements]] therefore is enough to write many kinds of queries. But there are many cases where the standard table output of a query may not be the best choice, or where further settings are desired (like the maximum number of results that should be displayed). For this purpose, inline queries have a number of other possible parameters that one can use to control their appearance in detail. The general syntax for <tt>#ask</tt> therefore is the following:
+
Knowing the basics of [http://semantic-mediawiki.org/wiki/Help:Selecting_pages query string] and [http://semantic-mediawiki.org/wiki/Help:Displaying_information printout statements] therefore is enough to write many kinds of queries. But there are many cases where the standard table output of a query may not be the best choice, or where further settings are desired (like the maximum number of results that should be displayed). For this purpose, inline queries have a number of other possible parameters that one can use to control their appearance in detail. The general syntax for <tt>#ask</tt> therefore is the following:
    
  <nowiki>{{</nowiki>#ask: <i>argument 1</i> | <i>argument 2</i> | &hellip; <nowiki>}}</nowiki>
 
  <nowiki>{{</nowiki>#ask: <i>argument 1</i> | <i>argument 2</i> | &hellip; <nowiki>}}</nowiki>
Line 40: Line 40:  
Most of this page explains the various arguments one may use in inline queries.
 
Most of this page explains the various arguments one may use in inline queries.
   −
Prior to Semantic MediaWiki 1.0 there was a different syntax for inline queries using an <tt><nowiki><ask></nowiki></tt> tag, which is still enabled on some wikis. Please see the [[Help:Inline queries 0.7|old documentation page]] for details on this feature. It is strongly recommended to use only the new syntax now.
+
Prior to Semantic MediaWiki 1.0 there was a different syntax for inline queries using an <tt><nowiki><ask></nowiki></tt> tag, which is still enabled on some wikis. Please see the [http://semantic-mediawiki.org/wiki/Help:Inline_queries_0.7 old documentation page] for details on this feature. It is strongly recommended to use only the new syntax now.
    
== The #show parser function ==
 
== The #show parser function ==
Line 59: Line 59:     
# Which pages are requested? ([http://semantic-mediawiki.org/wiki/Help:Selecting_pages query description])
 
# Which pages are requested? ([http://semantic-mediawiki.org/wiki/Help:Selecting_pages query description])
# What information should be displayed about those pages? ([[Help:Displaying information|printout statements]])
+
# What information should be displayed about those pages? ([http://semantic-mediawiki.org/wiki/Help:Displaying_information printout statements])
 
# How should the results be formatted within the page?
 
# How should the results be formatted within the page?
   Line 97: Line 97:  
| <tt>sort</tt>
 
| <tt>sort</tt>
 
| property name or a list of property names separated by ,
 
| property name or a list of property names separated by ,
| name of properties to use for sorting queries (see [[Help:Selecting pages]])
+
| name of properties to use for sorting queries (see [http://semantic-mediawiki.org/wiki/Help:Selecting_pages Selecting pages])
 
|-
 
|-
 
| <tt>order</tt>
 
| <tt>order</tt>
Line 195: Line 195:  
=== Sorting results ===
 
=== Sorting results ===
   −
It has been explained in [[Help:Selecting pages]] that query results can be ordered by one or more properties. As explained there, [[Special:Ask]] has additional input fields to specify sort properties and ordering. In inline queries, sort properties are defined with the parameter <tt>sort</tt>, and the order can be set with the parameter <tt>order</tt>. The value of <tt>order</tt> should be «<tt>ascending</tt>» or «<tt>descending</tt>», or one of the short forms «asc» and «desc», or «reverse». You can also set the value to «<tt>random</tt>» (or «<tt>rand</tt>») for ordering results in an essentially random way (this feature can be disabled by the site administrator, see [[Help:Configuration|Configuration]]). An example is the following query for the three largest cities in Germany:
+
It has been explained in [http://semantic-mediawiki.org/wiki/Help:Selecting_pages selecting pages] that query results can be ordered by one or more properties. As explained there, [[Special:Ask]] has additional input fields to specify sort properties and ordering. In inline queries, sort properties are defined with the parameter <tt>sort</tt>, and the order can be set with the parameter <tt>order</tt>. The value of <tt>order</tt> should be «<tt>ascending</tt>» or «<tt>descending</tt>», or one of the short forms «asc» and «desc», or «reverse». You can also set the value to «<tt>random</tt>» (or «<tt>rand</tt>») for ordering results in an essentially random way (this feature can be disabled by the site administrator, see [http://semantic-mediawiki.org/wiki/Help:Configuration Configuration]). An example is the following query for the three largest cities in Germany:
    
<pre>{{#ask: [[Category:City]] [[Located in::Germany]]
 
<pre>{{#ask: [[Category:City]] [[Located in::Germany]]
Line 358: Line 358:  
== Using templates for custom formatting ==
 
== Using templates for custom formatting ==
   −
Some of the above result formats support the use of wiki [[meta:Help:Template|template]] to fully control the display of an inline query. This works for the formats <tt>template</tt>, <tt>list</tt>, <tt>ol</tt> and <tt>ul</tt>. If a template is specified, all result «rows» are formatted using this template. The name of the template (without the initial «Template:») is given in the parameter <tt>template</tt>, so the query has the following general form:
+
Some of the above result formats support the use of wiki [http://semantic-mediawiki.org/wiki/meta:Help:Template template] to fully control the display of an inline query. This works for the formats <tt>template</tt>, <tt>list</tt>, <tt>ol</tt> and <tt>ul</tt>. If a template is specified, all result «rows» are formatted using this template. The name of the template (without the initial «Template:») is given in the parameter <tt>template</tt>, so the query has the following general form:
    
   <nowiki>{{#ask:</nowiki> ... | format=template/list/ol/ul | template=''templatename'' }}
 
   <nowiki>{{#ask:</nowiki> ... | format=template/list/ol/ul | template=''templatename'' }}

Navigation menu