Template:Query page

From Wikidata
Jump to navigation Jump to search
Documentation icon Template documentation[view · edit · history · purge ]

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}}

For a link to the query:

{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=link}}

For the URL to the embed page:

{{User:TweetsFactsAndQueries/Queries/EGOT winners|style=url embed}}

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

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
stylestyle

The style with which this query should be transcluded. Should always be passed through.

Default
{{{style|}}}
Stringrequired
titletitle

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.

Stringrequired
queryquery

The query itself. Escape any vertical bars as {{!}}.

Stringrequired
original tweet URLoriginal_tweet_url

The URL of a Twitter tweet where this query was originally published.

URLoptional
original toot URLoriginal_toot_url

The URL of a Mastodon toot where this query was originally published.

URLoptional
header wikitext (after “original…”)header_wikitext_after_original

Additional wikitext to append after the “originally published…” text from the tweet/toot URLs.

Contentoptional
header wikitext paragraphheader_wikitext_paragraph

Additional wikitext to append as a separate paragraph to the header.

Contentoptional
footer wikitextfooter_wikitext

A footer after the query.

Contentoptional