Compatible with DokuWiki
This plugin adds the possibility to display the structered data of the Data Plugin using templates. Templates can be applied to individual data entries or lists of multiple entries. Additionally, this plugin offers a custom search form, pagination and result caching.
Download and install the plugin using the Plugin Manager using the URL given above. Refer to Plugins on how to install plugins manually.
Templates are separate wiki pages containing placeholders. There are two kinds of placeholders:
@@, e.g. @@Title@@ will be replaced after the template page has been parsed for wiki instructions. The translation rules of the special types of the data plugin still apply. That is, a field with suffix _mail will be rendered as an e-mail link, etc.@@!Title@@ will be replaced before the template is processed by the Dokuwiki parser. This allows for more fine grained control under some circumstances, like the use of images.A template definition as in
=== @@Page@@ ===
{{@@!imgname@@?nolink&70 }}
**Phone**: @@phone@@ \\
**E-Mail**: @@email@@
will use whatever value is stored in the field imgname as file name in a standard Dokuwiki image syntax, leading to a left floating picture with phone and email to the right. If the email field was appended by _mail when listed in the cols parameter of the datatemplatelist, it will be correctly rendered as an email link.
This plugin provides 3 different syntax blocks. The first two are essentially the same as for the data plugin, but with an added template parameter:
datatemplateentry corresponds to the dataentry of the data plugin. Note that the template should use the names supplied to the headers parameter (if given) as placeholders for the substitutions.datatemplatelist corresponds to the datalist of the data plugin. Contrary to its “brother”, the datatemplatelist also supports pagination.
The value of the template parameter is a Dokuwiki page containing the template definition, as discussed above. A datatemplateentry could for example look like this:
---- datatemplateentry member ---- template : tpl_member firstname : Christoph lastname : Clausen type : PhD Student active : yes addr : GAP-Optique \\ Rue de l'Ecole de Medecine 20 \\ CH-1211 Geneve 4 ----
The filter form adds new functionality to the data and datatemplate plugins. It can be used on pages where there is already a datatable, datalist or datatemplatelist. An example of the syntax looks like this:
---- filterform ---- fields: Any, Title, Journal, Author, Volume, Page, Year, Abstract ----
The single parameter fields is turned into a dropdown list when the page is rendered. Its value is a list of column names or headers. Next to the dropdown list is a text field. When the form is submitted, only those data entries are displayed, where the column selected in the dropdown box contains the text in the text field. This effectively corresponds to adding a line like filter: Title~*weather* inside the source of e.g. the datatable.
It is possible to add more and more filter criteria by repeatedly submitting the form. Also, applied filters can later be removed individually.
For a demonstration, see for instance the Publications page of the Group of Applied Physics at the University of Geneva. There, both the datatemplate list and the filter form can be seen in action. Each item in the list is a datatemplate entry (created by a separate plugin that accepts BibTeX as input). The Members page is equally based on this plugin.
The data plugins stores its data as simple key-value pairs in an SQLite database. While this leads to a lot of flexibility, there is a disadvantage when querying the data from the database. To obtain something that looks like a result from “normal” SQL tables, the data plugin tailors together a series of JOIN operations, which can be very time consuming. To give some numbers, a single request with about 300 result items, as is the case for the list of publications mentioned above, took several seconds to resolve. Even though this does not seem too bad, it quickly becomes frustrating, when filtering and page navigation lead to several such requests in a row.
A simple caching technique in the datatemplate list significantly speeds up page queries. This essentially works as follows:
One can force a rebuild of the cache by using the Dokuwiki purge mechanism.
In the current state, this plugin leaves room for improvements. Some of the currently known issues are
However, there are no promises that these (or other) issues will be addressed in future releases.
This plugin was inspired by the dataloop plugin by Martyn Eggleton. Much of the template rendering code is based on the templater plugin by Jonathan Arkell.
Please submit bugs and feature requests in the issue tracker linked at the top.