Difference between revisions of "Manual:Semantic MediaWiki/Examples/Customer data/Queries"
← Manual:Semantic MediaWiki/Examples/Customer data/Queries
[quality revision] | [quality revision] |
(Tag: 2017 source edit) |
You can query and display the data that you collect in the wiki at at any time on any wiki page.
Contents
"Ask" queries[edit | edit source]
With the parser function "#ask", we can now use the semantic properties and the category association to show the collected data on our wiki pages.
As an example, we list the pages that collect customer data. You can include this "ask" query on any wiki page: {{#ask:
[[Category:Customer data]]
|?Has location
|?Has contact person
|?Has First contact
}}
This query first defines via the category Customer data that only pages within this category should be included in the data query (1).
Then, using the pipe-syntax |?
we define which property values we want to display (2).
The default results output is in a table format. The page from which the customer data originates is automatically added as a first column (this can be customized as needed).
Has location | Has contact person | Has First contact | |
---|---|---|---|
Hallo Welt GmbH | Regensburg | Jane Doe | 21 December 2020 |
Semantic MediaWiki/Examples/Customer data/Customer page | Berlin | David Wang | 18 December 2020 |
Adjusting the output format[edit | edit source]
The output of the data is very flexible and offers many customizing options. Let's look at some examples.
Table formatting[edit | edit source]
Output with adjusted table width of 100% (format=broadtable) and with adjusted column labels. The first column also gets a custom label (mainlabel=Customer):
Customer | Location | Contact | Date of first contact |
---|---|---|---|
Hallo Welt GmbH | Regensburg | Jane Doe | 21 December 2020 |
Semantic MediaWiki/Examples/Customer data/Customer page | Berlin | David Wang | 18 December 2020 |
{{#ask:
[[Category:Customer data]]
|?Has location = Location
|?Has contact person = Contact
|?Has First contact= Date of first contact
|mainlabel = Customer
|format= broadtable
}}
Simple page list[edit | edit source]
Output of pages that use the template "Customer data" in a list format:
Query: {{#ask:
[[Category:Customer data]]
|format= ul
}}
Adjusting the query[edit | edit source]
In semantic queries, results can be filtered by namespaces, categories and semantic attributes.
Examples[edit | edit source]
The following query shows all results for the namespace Manual and the category Customer data. The output shows the location of the customers:
{{#ask:[[Manual:+]] [[Category:Customer data]]
|?Has location = Location
}}
Result:
Location | |
---|---|
Semantic MediaWiki/Examples/Customer data/Customer page | Berlin |
The following query shows all results for the namespace Manual and for the namespace (Main)and' for the category customer data. All three selection criteria have to be valid for a page to be included in the results. (Note: The namespace (Main) is referenced as empty prefix (
:+
).
{{#ask:[[Manual:+||:+]] [[Category:Customer data]]
|?Has location = Location
|mainlabel = Customer
}}
Result:
Kunde | Location |
---|---|
Hallo Welt GmbH | Regensburg |
The following query shows the results from namespace Manual and from the category Customer data.
{{#ask:[[Category:Customer data]] [[Has location::Regensburg]]
|?Has location = Location
|mainlabel = Customer
}}
Result:
Customer | Location |
---|---|
Hallo Welt GmbH | Regensburg |
Related info
- https://www.semantic-mediawiki.org/wiki/Help:Inline_queries Help page for semantic inline queries
<bookshelf src="Book:Getting started with Semantic MediaWiki" /> {{DISPLAYTITLE:Semantic data queries}} You can query and display the data that you collect in the wiki at at any time on any wiki page. =="Ask" queries== With the parser function "#ask", we can now use the semantic properties and the category association to show the collected data on our wiki pages. As an example, we list the pages that collect customer data. You can include this "ask" query on any wiki page:<syntaxhighlight lang="text"> {{#ask: [[Category:Customer data]] |?Has location |?Has contact person |?Has First contact }} </syntaxhighlight> This query first defines via the category ''Customer data'' that only pages within this category should be included in the data query (1). Then, using the pipe-syntax <code>|?</code> we define which property values we want to display (2). <br /> [[File:Manual:ask-Abfrage-einfach-EN.png|alt=Simple "ask" query|center|thumb|300x300px|Simple "ask" query]] The default results output is in a table format. The page from which the customer data originates is automatically added as a first column (this can be customized as needed). <br /> {{#ask: [[Category:Customer data]] |?Has location |?Has contact person |?Has First contact }} ==Adjusting the output format== The output of the data is very flexible and offers many customizing options. Let's look at some examples. <br /> ===Table formatting=== Output with adjusted table width of 100% (format=broadtable) and with adjusted column labels. The first column also gets a custom label (mainlabel=Customer): {{#ask: [[Category:Customer data]] |?Has location = Location |?Has contact person = Contact |?Has First contact= Date of first contact |mainlabel = Customer |format= broadtable }}Query:<syntaxhighlight lang="text"> {{#ask: [[Category:Customer data]] |?Has location = Location |?Has contact person = Contact |?Has First contact= Date of first contact |mainlabel = Customer |format= broadtable }} </syntaxhighlight> ===Simple page list=== Output of pages that use the template "Customer data" in a list format: {{#ask: [[Category:Customer data]] |format= ul }} Query:<syntaxhighlight lang="text"> {{#ask: [[Category:Customer data]] |format= ul }} </syntaxhighlight> ==Adjusting the query== In semantic queries, results can be filtered by namespaces, categories and semantic attributes. ===Examples=== The following query shows all results for the namespace ''Manual'' and the category ''Customer data''. The output shows the location of the customers: <syntaxhighlight lang="text"> {{#ask:[[Manual:+]] [[Category:Customer data]] |?Has location = Location }} </syntaxhighlight> Result: {{#ask:[[Manual:+]] [[Category:Customer data]] |?Has location = Location }} <br />The following query shows all results for the namespace ''Manual'' '''and'' for the namespace ''(Main)'''''and'<nowiki/>'' for the category ''customer data''. All three selection criteria have to be valid for a page to be included in the results. (Note: The namespace (Main) is referenced as empty prefix (<code>:+</code>).<syntaxhighlight lang="text"> {{#ask:[[Manual:+||:+]] [[Category:Customer data]] |?Has location = Location |mainlabel = Customer }} </syntaxhighlight> Result: {{#ask:[[Handbuch:+||:+]] [[Category:Customer data]] |?Has location = Location |mainlabel = Kunde }} The following query shows the results from namespace ''Manual'' and from the category ''Customer data''. <syntaxhighlight> {{#ask:[[Category:Customer data]] [[Has location::Regensburg]] |?Has location = Location |mainlabel = Customer }} </syntaxhighlight> Result: {{#ask:[[Category:Customer data]] [[Has location::Regensburg]] |?Has location = Location |mainlabel = Customer }} {{Box Links-en|Topic1=[https://www.semantic-mediawiki.org/wiki/Help:Inline_queries https://www.semantic-mediawiki.org/wiki/Help:Inline_queries] Help page for semantic inline queries}} [[en:{{FULLPAGENAME}}]] [[de:Handbuch:Semantic_MediaWiki/Beispiele/Kundendaten/Abfrage]]
Line 1: | Line 1: | ||
+ | <bookshelf src="Book:Getting started with Semantic MediaWiki" /> | ||
{{DISPLAYTITLE:Semantic data queries}} | {{DISPLAYTITLE:Semantic data queries}} | ||