No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
|limit=4 | |limit=4 | ||
}} | }} | ||
</syntaxhighlight>Output example in list style format:<br />{{#ask: | </syntaxhighlight>Output example in list style format:<span /><br />{{#ask: | ||
[[:+]][[Modification date::+]] | [[:+]][[Modification date::+]] | ||
|format=ul | |format=ul | ||
Line 17: | Line 17: | ||
}} | }} | ||
<span><br /></span> | |||
'''Notes:''' | '''Notes:''' | ||
<span><br /></span> | |||
<code><nowiki>[[:+]]</nowiki></code> shows pages from the ''Main'' namespace. | <code><nowiki>[[:+]]</nowiki></code> shows pages from the ''Main'' namespace. | ||
Line 95: | Line 95: | ||
}} | }} | ||
<span><br /></span> | |||
===Format "datatable"=== | ===Format "datatable"=== | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
Line 123: | Line 123: | ||
}} | }} | ||
{{Box Links-en|Topic1=[https://www.semantic-mediawiki.org/wiki/Help:Inline_queries SMW "ask" queries]|Topic2=[https://www.semantic-mediawiki.org/wiki/Help:Result_formats SMW result formats]}}<br /> | |||
== <span class="mw-headline">Templates</span> == | |||
Customized output formats can be created using templates. The documentation for this can be found at [https://www.semantic-mediawiki.org/wiki/Help:Using_templates semantic-mediawiki.org.] | |||
Here we show you some useful tips when working with templates. | |||
=== Suppressing the namespace prefix === | |||
By default, the namespace prefix of a page is suppressed in the output formats "ul", "ol" (and other formats). However, if you are working with a template and therefore use the ''link=none'' parameter in the ask query, because you generate the link in the template yourself, then the page name is displayed with the namespace prefix. Sample query of all pages in the QM namespace: <div> | |||
<nowiki>{{#ask: </nowiki>[[QM:+]][[Modification date::+]] | |||
<nowiki>|</nowiki>format=plaintext | |||
<nowiki>|</nowiki>template=mytemplate | |||
<nowiki>|</nowiki>link=none | |||
}} | |||
</div>The output here is in the format '''''QM:My Page'''''. | |||
To remove the namespace prefix, use the following syntax in the template, e.g. to generate an unordered list:<div> | |||
*<nowiki>[[{{FULLPAGENAME:{{{1}}}}}|{{PAGENAME:{{{1}}}}}]]</nowiki> | |||
</div>In this example, the full page name is linked via the "magic word" <nowiki>{{FULLPAGENAME}}</nowiki> and the page name without namespace prefix <nowiki>{{PAGENAME}}</nowiki> is used as the link label. The resulting output is '''''My Page'''''.{{Box Links-en|Topic1=[https://www.semantic-mediawiki.org/wiki/Help:Inline_queries SMW "ask" queries]|Topic2=[https://www.semantic-mediawiki.org/wiki/Help:Result_formats SMW result formats]|Topic3=[https://semantic-mediawiki.org/wiki/Help:Using_templates Using templates to create output formats]}}<span /><br /> | |||
[[Category:Organization]] | [[Category:Organization]] | ||
[[de:SMW-Abfragen]] | [[de:SMW-Abfragen]] | ||
[[en:{{FULLPAGENAME}}]] | [[en:{{FULLPAGENAME}}]] |
Revision as of 09:45, 2 November 2022
Here you can see some examples for simple queries using the metadata of a wiki page. You can add these queries to any wiki page.
Creating page lists
Show pages in a particular namespace
{{#ask:
[[:+]] <!-- find all pages in the main namespace -->
[[Modification date::+]]<!-- necessary to filter deleted pages -->
|format=ul
|limit=4
}}
Output example in list style format:
- Accessibility
- Accessibility/Extensions
- Accessibility/Extensions/legacy list
- Accessibility/Extensions/notchecked
Notes:
[[:+]]
shows pages from the Main namespace.
[[Myspace:+]]
shows pages from the namespace Myspace.
[[:+||Help:+]]
shows pages from both the Main namespace and the namespace Help (=OR argument)
Output in category style
{{#ask:
[[:+]][[Modification date::+]]
|format=category
|limit=12
}}
A
A cont.
Show pages from a category
{{#ask:
[[Category:Administration]]
| limit=4
| searchlabel=
| format=ol
}}
Pages that start with the same page name string
{{#ask:
[[~Visu*]][[:+||Manual:+]]
[[Modification date::+]]<!-- necessary to filter deleted pages -->
| limit=5
| searchlabel=
| format=ol
}}
Results format: Table
Format "broadtable"
{{#ask:
[[~Visu*]][[:+||Manual:+]]
[[Modification date::+]]<!-- necessary to filter deleted pages -->
| limit=5
| searchlabel=
| format=broadtable
}}
Format "datatable"
{{#ask:
[[~Visu*]][[:+||Handbuch:+]]
[[Modification date::+]]<!-- necessary to filter deleted pages -->
| limit=5
| searchlabel=
| format=table
| class=datatable
}}
Templates
Customized output formats can be created using templates. The documentation for this can be found at semantic-mediawiki.org.
Here we show you some useful tips when working with templates.
Suppressing the namespace prefix
By default, the namespace prefix of a page is suppressed in the output formats "ul", "ol" (and other formats). However, if you are working with a template and therefore use the link=none parameter in the ask query, because you generate the link in the template yourself, then the page name is displayed with the namespace prefix. Sample query of all pages in the QM namespace:{{#ask: QM:++Property "Modification date" has a restricted application area and cannot be used as annotation property by a user. |format=plaintext |template=mytemplate |link=none }}
*[[{{FULLPAGENAME:{{{1}}}}}|{{PAGENAME:{{{1}}}}}]]
Related info