Template:Query page
A template for queries stored on a dedicated wiki page. Store the query using this template, and it can be transcluded into other wiki pages into a variety of formats.
Examples
[edit]Two examples have been set up at Template:query page/sandbox and Template:query page/sandbox 2. See their talk pages for examples of the transclusion styles.
Query page usage
[edit]This template is meant to be used once on a wiki page, with no other content on the page (making that page a “query page”). To use multiple queries on a page, create one subpage per query, then transclude each subpage into your main page as discussed below.
Minimal example:
{{query page
|style={{{style|}}}
|title=Some title
|query=SELECT (1 AS ?example) WHERE {}
}}
Typical example:
{{query page
|style={{{style|}}}
|title=Some title
|original_tweet_url=https://twitter.com/WikidataFacts/...
|original_toot_url=https://mastodon.social/@WikidataFacts/...
|query=SELECT (1 AS ?example) WHERE {}
}}
For the full list of parameters, see the template data.
Note that the above inputboxes don’t add any prefix to the title.
If you’re planning to use this template regularly,
you probably want to copy them to some subpage of your user page and add an appropriate prefix
parameter there.
See the inputbox at User:TweetsFactsAndQueries/Queries for an example of this.
Transclusion usage
[edit]Suppose you want to use/reference the query that’s stored at User:TweetsFactsAndQueries/Queries/EGOT winners.
For a {{SPARQL}}
block:
{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=SPARQL}}
Result |
---|
# people who won an Emmy, Grammy, Oscar, and Tony Award (“EGOT”)
# (may include non-competitive awards)
SELECT ?person ?personLabel WITH {
SELECT DISTINCT ?person WHERE {
?person wdt:P31 wd:Q5;
p:P166/ps:P166/(wdt:P31|wdt:P279)* wd:Q123737, wd:Q41254, wd:Q19020, wd:Q191874.
}
} AS %results WHERE {
INCLUDE %results.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
|
For a link to the query:
{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=link}}
Result |
---|
For the URL to the embed page:
{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=url embed}}
Result |
---|
For the plain query text, typically used in another template (e. g. {{Wikidata list}}
):
{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=query}}
Full list of styles:
Template data
[edit]A template for queries stored on a dedicated wiki page
Parameter | Description | Type | Status | |
---|---|---|---|---|
style | style | The style with which this query should be transcluded. Should always be passed through.
| String | required |
title | title | The title used for linking to this query. Often related to the base page name. Can use the LangSwitch template to specify titles in different languages. | String | required |
query | query | The query itself. Escape any vertical bars as {{!}}. | String | required |
original tweet URL | original_tweet_url | The URL of a Twitter tweet where this query was originally published. | URL | optional |
original toot URL | original_toot_url | The URL of a Mastodon toot where this query was originally published. | URL | optional |
header wikitext (after “original…”) | header_wikitext_after_original | Additional wikitext to append after the “originally published…” text from the tweet/toot URLs. | Content | optional |
header wikitext paragraph | header_wikitext_paragraph | Additional wikitext to append as a separate paragraph to the header. | Content | optional |
footer wikitext | footer_wikitext | A footer after the query. | Content | optional |
The above documentation is transcluded from Template:Query page/doc (edit | history). Editors can experiment in this template's sandbox (edit | diff) and testcases (create) page. Please add categories to the /doc subpage. Subpages of this template. |