Extension:VisualData/QueryLink parser function

From mediawiki.org

Since version 1.0.4b, VisualData includes a "querylink" parser function (with the following aliases: "visualdataquerylink", "vdataquerylink") through which to simply create query links in order to print dynamically content based on the query string in the target page.

The syntax for the "querylink" parser function is the following:

{{#querylink:Target page|Read more|class=my-class|pageid=123}}


The first parameter is the target page, the second parameter is the button label (if not set the title of the target page will be used), the optional "class" parameter sets the class for the link, and additional named parameters will be used to build the query itself.

In the previous example, the pageid is obtained within a template called from any visualdataquery, where the parameters pagetitle and articleid are always available together the other retrieved properties. Therefore the parser function above becomes:

{{#querylink:Target page|Read more|class=my-class|pageid={{{articleid}}} }}


Finally, the target page may contain a parser function like the following

{{#visualdataprint:{{#urlget:pageid}}
|schema=Experience
|?testimony
|format=raw
}}

in order to print dynamically content based on the query string (note that the name itself of the query attribute is arbitrary). Although an implementation is fairly simple, the query attribute is retrieved using Extension:UrlGetParameters and therefore this extension is required.

This tool can be useful when you store complex data in articles with json content model as main slot, and you want to display all or some of these data to visitors through standard wikitext. It can be used in all cases where the "item" page is dynamic and updated often, or has a similar formatting for the same kind of items, like for online catalogues and shops.


See also[edit]