Extension:VisualData/Result formats

Json

Json result format uses the Mediawiki's native implementation JsonContent::rootValueTable and is useful to print the data related to a single article especially with a hierarchical structure. Note indeed the parser function visualdataprint used to retrieve the data associated to the article "Demo_VisualData" (the first argument of the function)

{{#visualdataprint: Demo_VisualData
|?cover
|?title
|?authors/name
|?authors/email
|schema=Book
|format=json
}}



Shown data are automatically updated when the source data are edited through the tab "Edit data" or through a VisualData form editing the same data (namely using the parameter edit-page = {{FULLPAGENAME}}, or the name of the target page).


Table

Table and Datatables are typically used with the parser function visualdataquery (that as mentioned allows to query data from multiple pages). Since version 1.09 VisualData allows to display tables and datatables in two different mode: "plain" and "nested". (default is "auto", usually "plain" will be used if all the requested printouts are on the same hierarchical level, regardless of whether they are arrays or not). If set to "plain" the rows will be repeated in case of multiple entries and if set to "nested" multiple items are rendered in the same row.

Anyway the "plain" mode is encouraged by this format as a good practice, since tables should always contain same-level relationships and multiple tables also built from the same data should be used to display multi-level or hierarchical relationships.

Here is a parser function to display the data related to a specific article as a table:

{{#visualdataprint: Demo_VisualData
|?cover
|?title
|?authors/name
|?authors/email
|schema=Book
|format=table
}}


(note that only the author's first name is different for each row, read above for more information)


Also note the following:

  • table's headings by default are the field labels as defined in the Schema Builder (if the label is not defined, the name will be used)
  • pagetitle is always available and contains the link of the related wiki article.
  • to disable the pagetitle column use the parameter pagetitle=
  • each field name can be customized using the form name=alias where "name" is the original name and "alias" is the new assigned name
  • to hide a given field but in the same time to retrieve its value to make it available as template parameter, use the following form name=
  • the content of each cell can be further processed using a template. For instance to print the cover thumbnail in the Cover field, set a parameter like template?cover = Book-cover and then create a template with name "Book-cover" and content
[[{{{cover}}}|300px|frameless]]

Also note that in each referenced template are always available all other computed properties, as named parameters, plus "pagetitle", "articleid", "isfirst" and "islast" (useful with arrays). This way each cell can reference all other cells for "endless" customization. See for instance here, a CRUD with a table cell containing another VisualData popup form, allowing to edit the row itself.


(see here for the template applied to the cell "action")

Note also that new empty cells can be simply added to the table requesting a non-existing printout in the same parser-function, like |?additional cell, then applying a template to the same cell (unless you don't want to keep it empty) and finally referencing other fields where required.

Since version 1.09 table and datatable formats contain an additional parameter "mode" determining how entries are queried and shown in the table. If "auto" the mode will be automatically determined, if set to "plain" the rows will be repeated in case of multiple entries and if set to "nested" multiple items are rendered in the same row. See here https://wikisphere.org/wiki/Demo_VisualData/Test_table for a demo.


allowed paramaters
parameterdescriptiondefault
modetable mode: "auto", "plain" or "nested". If "plain" rows are repeated in case of multiple entries; if nested multiple items are rendered in the same rowauto


Datatable

All the features of the result format "table" are applicable to the result format "datatables" as well. Note that in this case makes more sense to use the parser function visualdataquery since a datatable is expected to contain also large set of data retrieved from multiple wiki articles. In this case therefore the first argument of the parser function is a query, the second argument as above is the schema, and the parameters starting with a question mark represent a printout. The current version of the extension does not allow Ajax navigation with Datatables, therefore it is recommended to add a parameter limit = 100. (or some reasonable limit)

{{#visualdataquery:[[name::Afghanistan]] [[states/name::Badakhshan]]
|schema=Country 
|?states/cities/name
|?states/cities/latitude
|?states/cities/longitude
|format=datatable 
}} 


Since version 1.08b datatables format also supports Searchpanes and Ajax navigation

Here are the available parameters:

allowed paramaters
parameterdescriptiondefault
datatables-layout.topStarthttps://datatables.net/reference/option/layoutpageLength
datatables-layout.topEndhttps://datatables.net/reference/option/layoutsearch
datatables-layout.bottomStarthttps://datatables.net/reference/option/layoutinfo
datatables-layout.bottomEndhttps://datatables.net/reference/option/layoutpaging
datatables-autoWidthhttps://datatables.net/reference/option/autoWidthfalse
datatables-deferRenderhttps://datatables.net/reference/option/deferRenderfalse
datatables-infohttps://datatables.net/reference/option/infotrue
datatables-lengthChangehttps://datatables.net/reference/option/lengthChangetrue
datatables-orderinghttps://datatables.net/reference/option/orderingtrue
datatables-paginghttps://datatables.net/reference/option/pagingtrue
datatables-processinghttps://datatables.net/reference/option/processingfalse
datatables-scrollXhttps://datatables.net/reference/option/scrollXfalse
datatables-scrollYhttps://datatables.net/reference/option/scrollYfalse
datatables-searchinghttps://datatables.net/reference/option/searchingtrue
datatables-stateSavehttps://datatables.net/reference/option/stateSavefalse
datatables-displayStarthttps://datatables.net/reference/option/displayStart0
datatables-pagingTypehttps://datatables.net/reference/option/pagingTypefull_numbers
datatables-pageLengthhttps://datatables.net/reference/option/pageLength10, 20, 50, 100, 200
datatables-lengthMenuhttps://datatables.net/reference/option/lengthMenufalse
datatables-scrollCollapsehttps://datatables.net/reference/option/scrollCollapsefalse
datatables-scrollerhttps://datatables.net/reference/option/scrollerfalse
datatables-scroller.displayBufferhttps://datatables.net/reference/option/scroller.displayBuffer50
datatables-scroller.displayBufferhttps://datatables.net/reference/option/50
datatables-scroller.loadingIndicatorhttps://datatables.net/reference/option/scroller.loadingIndicatorfalse
datatables-buttonshttps://datatables.net/reference/option/buttons -- supported buttons/formats are: colvis, copy, csv, excel, pdf and print
datatables-fixedHeaderhttps://datatables.net/reference/option/fixedHeaderfalse
datatables-responsivehttps://datatables.net/reference/option/responsivetrue
datatables-keyshttps://datatables.net/reference/option/keysfalse
datatables-columns.widthhttps://datatables.net/reference/option/columns.width
datatables-searchPaneshttps://datatables.net/reference/option/searchPanesfalse
datatables-searchPanes.emptyMessagehttps://datatables.net/reference/option/searchPanes.emptyMessagetrue
datatables-searchPanes.collapsehttps://datatables.net/reference/option/searchPanes.collapsetrue
datatables-searchPanes.columnshttps://datatables.net/reference/option/searchPanes.columns
datatables-searchPanes.thresholdhttps://datatables.net/reference/option/searchPanes.threshold0.6
datatables-searchPanes.minCountcustom parameter1
datatables-searchPanes.showEmptycustom parameterfalse
datatables-searchPanes.htmlLabelshttps://datatables.net/reference/option/searchPanes.htmlLabelsfalse
datatables-cardscustom parameter (display rows as cards)false
datatables-synchcustom parameter (checks for new data each n seconds, if so it displays a button through which retrieve the original query through Ajax)false
datatables-synch.intervalcustom parameter (datatables-synch interval, in seconds)100
datatables-synch.propertyspecial property (technically a "prefix") used to detect data changes, can be "Creation date" or "Modification date"Creation date


Additionally, printout parameters in the style of SMW are also supported in the form:

?title |+datatables-columns.type=string |+datatables-width=50px 

(all those listed here https://datatables.net/reference/option/columns might be supported but haven't been extensively tested)


See here https://wikisphere.org/wiki/Demo_VisualData/Dynamic_catalogue for SearchPanes in action !!


Template

The template result format is able to print hierarchical/nested data applying recursively specified templates for each of its components. This way is relatively easy to create/edit infoboxes also with one-to-many relationships, and possibly to appreciate them more (from the Enterprise MW Spring conference 2023).


{{#visualdataprint: Demo_VisualData
|?cover
|?title
|?authors/name
|?authors/email
|schema=Book
|template=Book
|template?authors=Book authors
|format=template
}}


In the related parser function there is a template applied at schema level, "Book", with the following content

{| class="wikitable infobox"
! Title
| {{{title}}}
|-
! Authors
| {{{authors}}}
|-
! Cover
| [[{{{cover}}}|center|200px]]
|}

and a template for the subitem authors with the following content

<div style="border:1px solid #ccc; padding: 12px">
name: {{{name}}}

email: {{{email}}}
</div>

It is important to note that the subitems "authors" are inserted in the root template through the corresponding named parameter, and that the parameters name of child items (name and email pairs), when accessed from the related template (called with the parameter template?authors=Book authors) correspond to the field names, not to the complete properties path (called "printout" in the dialect of VisualData).

As usual, in the same template other possible fields on the same level are available through their names, plus the standard parameters "pagetitle" and "articleid".

Since version 1.0.4 nested properties can be accessed with their complete path without the need to associate an additional template for that. E.g. when creating a Geolocation item, the latitude and longitude fields can be accessed from the root template simply through their named parameters {{{geolocation/latitude}}} and {{{geolocation/longitude}}}. This currently does not apply in case of multiple subitems and a dedicated template must be used in this case, as described above.

Since version 1.0.9 all the parameters passed to a template by the visualdataquery parser function are visible using the parameters {{{params}}} or {{{_params}}} -- so that editors know which parameters are passed to the template and can use them properly.

For instance the output visible on the page using {{{params}}} inside https://wikisphere.org/wiki/Template:Book will be the following:

{
    "title": "The first men in the moon",
    "cover": "File:First_Men_in_the_Moon_(1901)_frontispiece.jpg",
    "authors": "
\nname: Herbert  Wells\n\nemail: \n
\nname: George Wells\n\nemail: \n
",
    "authors/1/email": "",
    "authors/1/first_name": "George",
    "authors/1/last_name": "Wells",
    "authors/1/name": "George Wells",
    "_title": "Demo VisualData",
    "_pagetitle": "Demo VisualData",
    "pagetitle": "Demo VisualData",
    "_pageid": 419,
    "pageid": 419,
    "articleid": 419,
    "_articleid": 419
}

(note that the sub-template inside the authors parameter/printout has been already expanded. Of course {{{params}}} or {{{_params}}} can be used in any sub-template as well)



The carousel format allows to easily display images slideshow using the Slick Javascript library, out of lists of pictures (completed with title, caption, and link) recorded through VisualData. It has been inspired by the corresponding SMW result format, and it supports virtually all parameters of the Slick library using the prefix "slick-", as follows:

{{#visualdataprint: {{FULLPAGENAME}}
|schema=File upload  
|format=carousel  
|file-property=file       
|caption-property=caption   
|slick-autoplaySpeed=7000
|slick-dots=true 
|slick-adaptiveHeight=true
}}

(this parser function assumes that the current page has associated a schema named "File upload" with a property named "file" and a property named "caption": they can also be within an array)



Here are the available parameters. To find out more about each of them please check the official documentation of the Slick library.


allowed paramaters
parameterdescriptiondefault
widthwidth of the carousel100%
heightheight of the carousel
classone or more classes applied to the container
file-propertydefault property used for the file namefile
title-propertydefault property used for the titletitle
caption-propertydefault property used for the captioncaption
link-propertydefault property used for the linklink
slick-accessibilityEnables tabbing and arrow key navigation. Unless autoplay: true, sets browser focus to current slide (or first of current slide set, if multiple slidesToShow) after slide change. For full a11y compliance enable focusOnChange in addition to this.true
slick-adaptiveHeightAdapts slider height to the current slidefalse
slick-autoplayEnables auto play of slidestrue
slick-autoplaySpeedAuto play change interval3000
slick-centerModeEnables centered view with partial prev/next slides. Use with odd numbered slidesToShow counts.false
slick-centerPaddingSide padding when in center mode. (px or %)50px
slick-cssEaseCSS3 easinease
slick-dotsCurrent slide indicator dotsfalse
slick-dotsClassClass for slide indicator dots containerslick-dots
slick-draggableEnables desktop draggingtrue
slick-easinganimate() fallback easinglinear
slick-edgeFrictionResistance when swiping edges of non-infinite carousels0.15
slick-fadeEnables fadefalse
slick-focusOnSelectEnable focus on selected element (click)false
slick-focusOnChangePuts focus on slide after changefalse
slick-infiniteInfinite loopingtrue
slick-initialSlideSlide to start on0
slick-lazyLoadAccepts 'ondemand' or 'progressive' for lazy load technique. 'ondemand' will load the image as soon as you slide to it, 'progressive' loads one image after the other when the page loads.ondemand
slick-mobileFirstResponsive settings use mobile first calculationfalse
slick-nextArrowAllows you to select a node or customize the HTML for the "Next" arrow.<button type="button" class="slick-next">Next</button>
slick-pauseOnDotsHoverAdapts slider height to the current slidefalse
slick-pauseOnFocusPauses autoplay when slider is focussedtrue
slick-pauseOnHoverPauses autoplay on hovertrue
slick-prevArrowAllows you to select a node or customize the HTML for the "Previous" arrow.<button type="button" class="slick-prev">Previous</button>
slick-respondToWidth that responsive object responds to. Can be 'window', 'slider' or 'min' (the smaller of the two).window
slick-rowsSetting this to more than 1 initializes grid mode. Use slidesPerRow to set how many slides should be in each row.1
slick-rtlChange the slider's direction to become right-to-leftfalse
slick-slideSlide element query
slick-slidesPerRowWith grid mode initialized via the rows option, this sets how many slides are in each grid row.1
slick-slidesToScroll# of slides to scroll at a time1
slick-slidesToShow# of slides to show at a time1
slick-speedTransition speed300
slick-swipeEnables touch swipetrue
slick-swipeToSlideSwipe to slide irrespective of slidesToScrollfalse
slick-touchMoveEnables slide moving with touchtrue
slick-touchThresholdTo advance slides, the user must swipe a length of (1/touchThreshold) * the width of the slider.5
slick-useCSSEnable/Disable CSS Transitionstrue
slick-useTransformEnable/Disable CSS Transformstrue
slick-variableWidthDisables automatic slide width calculationfalse
slick-verticalVertical slide directionfalse
slick-verticalSwipingChanges swipe direction to verticalfalse
slick-waitForAnimateIgnores requests to advance the slide while animatingtrue
slick-zIndexSet the zIndex values for slides, useful for IE9 and lower1000
slick-enable-lazyLoad-afterenable lazy load after the given threshold10


See here https://wikisphere.org/wiki/Demo_VisualData/Carousel the Carousel in action !!


Map

The map format is a simple implementation of Leaflet and Leaflet.MarkerCluster (see also). Currently it does not include a geocoder, however for large data-sets it's a better practice to first retrieve the geolocation for your items, store it within your data, and use as needed. (VisualData includes however a Geolocation UI within forms, based on MapTiler).


The map format can be used in a visualdataquery as follows:

{{#visualdataquery: [[name::United States]]
|schema=Country       
|?states/name     
|?states/latitude    
|?states/longitude 
|template=Map popup 
|lat-property=latitude
|lon-property=longitude
|title-property=name
|markerCluster=false
|width=100%
|height=380px
|format=map
|limit=1000
}}


which retrieves all the states of a given country, completed with their geolocation (printouts states/latitude and states/longitude) and displays them through a map. The template parameter (if used) is only used to display the popup content for each item and it's exclusive with the title-property.



(See here https://wikisphere.org/wiki/Demo_VisualData/Dynamic_catalogue in action !!)


allowed paramaters
parameterdescriptiondefault
tileLayer.attributionhttps://leafletjs.com/reference.html#tilelayer-attribution© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors
tileLayer.minZoomhttps://leafletjs.com/reference.html#tilelayer-minzoom0
tileLayer.maxZoomhttps://leafletjs.com/reference.html#tilelayer-maxzoom19
tileLayer.maxNativeZoomhttps://leafletjs.com/reference.html#tilelayer-maxnativezoom19
tileLayer.minNativeZoomhttps://leafletjs.com/reference.html#tilelayer-minnativezoom0
tileLayer.subdomainshttps://leafletjs.com/reference.html#tilelayer-subdomainsabc
tileLayer.errorTileUrlhttps://leafletjs.com/reference.html#tilelayer-errortileurl0
tileLayer.zoomOffsethttps://leafletjs.com/reference.html#tilelayer-zoomoffset
tileLayer.tmshttps://leafletjs.com/reference.html#tilelayer-tmsfalse
tileLayer.zoomReversehttps://leafletjs.com/reference.html#tilelayer-zoomreversefalse
tileLayer.detectRetinahttps://leafletjs.com/reference.html#tilelayer-detectretinafalse
tileLayer.crossOriginhttps://leafletjs.com/reference.html#tilelayer-crossoriginfalse
tileLayer.referrerPolicyhttps://leafletjs.com/reference.html#tilelayer-referrerpolicyfalse
tileLayer.tileSizehttps://leafletjs.com/reference.html#tilelayer-tilesize256
tileLayer.opacityhttps://leafletjs.com/reference.html#tilelayer-opacity1.0
tileLayer.updateWhenIdlehttps://leafletjs.com/reference.html#tilelayer-updatewhenidlefalse
tileLayer.updateWhenZoominghttps://leafletjs.com/reference.html#tilelayer-updatewhenzoomingfalse
tileLayer.updateIntervalhttps://leafletjs.com/reference.html#tilelayer-updateinterval200
tileLayer.zIndexhttps://leafletjs.com/reference.html#tilelayer-zindex1
tileLayer.noWraphttps://leafletjs.com/reference.html#tilelayer-nowrapfalse
tileLayer.panehttps://leafletjs.com/reference.html#tilelayer-panetilePane
tileLayer.classNamehttps://leafletjs.com/reference.html#tilelayer-classname
tileLayer.keepBufferhttps://leafletjs.com/reference.html#tilelayer-keepbuffer
map.zoomhttps://leafletjs.com/reference.html#map-zoom13
map.minZoomhttps://leafletjs.com/reference.html#map-minzoom0
map.maxZoomhttps://leafletjs.com/reference.html#map-maxzoom18
map.zoomControlhttps://leafletjs.com/reference.html#map-zoomcontroltrue
map.scrollWheelZoomhttps://leafletjs.com/reference.html#map-scrollwheelzoomtrue
map.boxZoomhttps://leafletjs.com/reference.html#map-boxzoomtrue
map.doubleClickZoomhttps://leafletjs.com/reference.html#map-doubleclickzoomtrue
map.dragginghttps://leafletjs.com/reference.html#map-draggingtrue
map.keyboardhttps://leafletjs.com/reference.html#map-keyboardtrue
map.fadeAnimationhttps://leafletjs.com/reference.html#map-fadeanimationtrue
map.zoomAnimationhttps://leafletjs.com/reference.html#map-zoomanimationtrue
map.attributionControlhttps://leafletjs.com/reference.html#map-attributioncontroltrue
map.trackResizehttps://leafletjs.com/reference.html#map-trackresizetrue
markerClusterGroup.showCoverageOnHoverhttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#optionsfalse
markerClusterGroup.zoomToBoundsOnClickhttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#optionstrue
markerClusterGroup.spiderfyOnMaxZoomhttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#optionstrue
markerClusterGroup.removeOutsideVisibleBoundshttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#optionstrue
markerClusterGroup.animatehttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#optionstrue
markerClusterGroup.animateAddingMarkershttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#optionsfalse
markerClusterGroup.maxClusterRadiushttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#options80
markerClusterGroup.disableClusteringAtZoomhttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#options18
markerClusterGroup.singleMarkerModehttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#optionsfalse
markerClusterGroup.spiderfyDistanceMultiplierhttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#options1.2
markerClusterGroup.chunkedLoadinghttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#optionstrue
markerClusterGroup.chunkIntervalhttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#options200
markerClusterGroup.chunkDelayhttps://github.com/Leaflet/Leaflet.markercluster?tab=readme-ov-file#options50
icon.iconUrlhttps://leafletjs.com/reference.html#icon-iconurlmarker-icon.png
icon.iconRetinaUrlhttps://leafletjs.com/reference.html#icon-iconretinaurlmarker-icon-2x.png
icon.iconSizehttps://leafletjs.com/reference.html#icon-iconsize25, 41
icon.iconAnchorhttps://leafletjs.com/reference.html#icon-iconanchor12, 41
icon.popupAnchorhttps://leafletjs.com/reference.html#icon-popupanchor1, -34
icon.shadowUrlhttps://leafletjs.com/reference.html#icon-shadowurlmarker-shadow.png
icon.shadowSizehttps://leafletjs.com/reference.html#icon-shadowsize41, 41
icon.shadowAnchorhttps://leafletjs.com/reference.html#icon-shadowanchor12, 41
popup.maxWidthhttps://leafletjs.com/reference.html#popup-maxwidth300
popup.minWidthhttps://leafletjs.com/reference.html#popup-minwidth150
popup.maxHeighthttps://leafletjs.com/reference.html#popup-maxheight200
popup.autoPanhttps://leafletjs.com/reference.html#popup-autopantrue
popup.autoPanPaddinghttps://leafletjs.com/reference.html#popup-autopanpadding50, 50
popup.closeButtonhttps://leafletjs.com/reference.html#popup-closebuttontrue
popup.closeOnEscapeKeyhttps://leafletjs.com/reference.html#popup-closeonescapeKeytrue
popup.classNamehttps://leafletjs.com/reference.html#popup-classname
popup.offsethttps://leafletjs.com/reference.html#popup-offset10, -10
popup.zoomAnimationhttps://leafletjs.com/reference.html#popup-zoomanimationtrue
marker.draggablehttps://leafletjs.com/reference.html#marker-draggablefalse
marker.keyboardhttps://leafletjs.com/reference.html#marker-keyboardtrue
marker.titlehttps://leafletjs.com/reference.html#marker-title
marker.althttps://leafletjs.com/reference.html#marker-alt
marker.zIndexOffsethttps://leafletjs.com/reference.html#marker-zindexoffset1000
marker.opacityhttps://leafletjs.com/reference.html#marker-opacity0.8
marker.riseOnHoverhttps://leafletjs.com/reference.html#marker-riseonhovertrue
marker.riseOffsethttps://leafletjs.com/reference.html#marker-riseoffset500
marker.panehttps://leafletjs.com/reference.html#marker-panemarkerPane
marker.autoPanhttps://leafletjs.com/reference.html#marker-autopanfalse
marker.autoPanPaddinghttps://leafletjs.com/reference.html#marker-autopanpadding50, 50
marker.autoPanSpeedhttps://leafletjs.com/reference.html#marker-autopanspeed20
map.fitBounds.animatehttps://leafletjs.com/reference.html#fitbounds-options-animate
map.fitBounds.durationhttps://leafletjs.com/reference.html#fitbounds-options-duration0.25
map.fitBounds.easeLinearityhttps://leafletjs.com/reference.html#fitbounds-options-easelinearity0.25
map.fitBounds.noMoveStarthttps://leafletjs.com/reference.html#fitbounds-options-nomovestartfalse
map.fitBounds.paddingTopLefthttps://leafletjs.com/reference.html#fitbounds-options-paddingtopleft0,0
map.fitBounds.paddingBottomRighthttps://leafletjs.com/reference.html#fitbounds-options-paddingbottomright0,0
map.fitBounds.paddinghttps://leafletjs.com/reference.html#fitbounds-options-padding0,0
lat-propertyname of property used for latitudelatitude
lon-propertyname of property used for longitudelongitude
title-propertyname of property used for marker titlename
heightmap's height380px
widthmap's width100%
markerClusterenable marker clusterfalse
markerTooltipenable marker tooltiptrue
ignoreEmptyCoordinatesignore empty coordinatestrue


Raw

This is just an alias for the template result formats, semantically used to print single value(s) either using or not separators. The following query for instance queries just the "title" property of a schema "Book" with data stored in the jsondata slot of the current article (as usual). The separators parameters are declared but won't have effect in this case.

{{#visualdataprint:{{FULLPAGENAME}} 
|schema=Book 
|format=raw 
|?title
|separator=<br />
|values-separator=,
|limit=1
}}

This kind of query is also useful to easily perform join queries in the controller itself (i.e. the template in Mediawiki's context, with reference of the MVC pattern) using the result of the query as part of the query of an outer visualdata query. See here for more information.


Lua

The Lua result format enables a module parameter to which the output of the query will be passed. It is intended for advanced users who needs to pre-process the result of the query using the flexibility of Lua scripting and to generate the output directly from the module. It can be used in the following way:


{{#visualdataquery:[[title::+]]
|schema=Book
|format=lua
|module=Handle query
|order=title asc
}}


then the query output can be accessed by the module Module:Handle query using

local origArgs = (type(frame.getParent) == "function") and frame:getParent().args or frame
local success, json = pcall(mw.text.jsonDecode, origArgs[0])

or

local json = mw.text.jsonDecode(origArgs[0])


Since version 1.08b a VisualData query can be performed directly from a Lua module using this code:

local ret = mw.visualdata.query( schema (string), query (string), printouts (list or table), params (table)  )

where the parameter query accepts the same format of the regular parser function (including a specific article id or title) the printouts expects a list of printouts (json paths without indexes) and the params accepts limit, order and offset.


count

Returns the number of results returned by the query.


pageid

Returns the pageid(s) of the matched article(s) by a query


pagetitle

Returns the article title(s) of the matched article(s) by a query


json-raw

Outputs the result in raw json (it is internally used by the function getQueryResults) and it is deprecated for the use in wiki articles in favor of the Lua format or the Lua function mw.visualdata.query.


table-raw

An internal result format used for the VisualData/API.


Custom result formats

Since each format is internally implemented as a separate class, third party extensions can easily implement their own result formats by adding them to the global variable $GLOBALS['wgVisualDataResultPrinterClasses']['new-result-format] = NewResultFormat; and then creating a class (in this case "NewResultFormat") that extends MediaWiki\Extension\VisualData\ResultPrinter. [1]


See also


  1. Note that result printers belong to 2 different groups: hierarchical/nested result printers (like "json" and "template") and plain/flatted result printers (like "table" and "datatables"). The first groups the results by article/page, as Semantic MediaWiki, by contrast to the second group. Each group therefore invokes the query engine in different way and new result formats shall take that into account.