dokuwiki-strata icon indicating copy to clipboard operation
dokuwiki-strata copied to clipboard

Suggestion: Include a query from another page

Open pop-ch opened this issue 3 years ago • 4 comments

The [[]] operand is essential for queries to find rows which refer to “self”. However, when the query is repeated on a largish number of pages for the same entity type, maintaining the queries becomes quite cumbersome and error prone.

An obvious solution would be to place the query into a separate page and to include it into the pages where it is to be rendered using the include plugin. This would make it very easy to change the query for a great number of pages. However, this will not work because the [[]] refers to the page where the query is stored and not to the main page being rendered. In fact, the [[]] notation is not even needed because just writing down the fully qualified id of the page would suffice.

The Dokuwiki plugin struct (which serves roughly the same purpose) can do that. Apparently, it defines the symbol which stands for self as the main page being rendered and not as the page where the query is stored.

The suggestion: add a new function referring to the page being rendered so that the query can be placed in different page from the base data. I think the semantics for [[]] should not be changed so as not to break existing code.

I like the query language in strata very much and I think it's much more powerful than comparable plugins. Was it based on QBE? Thank you very much for this nice work.

pop-ch avatar Jul 18 '20 10:07 pop-ch

I'm happy that Strata still proves useful to people!

Your idea of using the include plugin is also the first thing I tried to do --- nobody likes repeating a query fifty times and discovering that they need to change them all. Unfortunately, the include plugin takes steps to make sure that included part renders as if it were still on the included page. Instead of building the required functionality into Strata for this specific case, I opted to take a more comprehensive approach: templating instead of inclusion.

You can get query inclusion (and much more) by using the following two plugins I wrote:

(These two plugins might not be in complete working order on modern PHP, their last updates were 4 years ago. Do open issues if you find incompatibility issues)

  • dokuwiki-plugin-templatery, which is a general purpose templating plugin for dokuwiki. It is built on replacement syntax, instead of string manipulation; and it renders as-if on the page the template is rendered on, instead of the page the template is stored on.
  • dokuwiki-plugin-stratatemplatery which adds the necessary features to combine Strata and Templatery. This allows you to define templates used to display <data project> blocks, and templates for displaying query results.

To get the functionality you suggest you can add your query to a template, and include the query with {{template>query_template_page}}, or you can add a query to the project template so it is automatically included anywhere a project is defined.


The query language is inspired by QBE and SPARQL. The fundamental approach of the query language is describing a graph structure with variables (but without path queries, due to complexity of implementation). Conceptually execution of the query is performed by matching the query graph pattern to the data graph, which produces a mapping of variables to concrete values for each match.

bwanders avatar Jul 19 '20 13:07 bwanders

Thank you very much for your exhaustive reply. I have tried to install the templatery and failed. I have raised an issue on the templatery page. I would like very much to have a working version of this plugin, as I think it would solve other issues I found in my projects.

pop-ch avatar Jul 19 '20 22:07 pop-ch

I have updated all listed utility plugins from my previous post to be compatible with DokuWiki release 2020-07-29 "Hogfather".

bwanders avatar Aug 09 '20 14:08 bwanders

Thank you very much. They now load without crashing Dokuwiki. Very interesting. I'm looking forward to explore the new functionality.

pop-ch avatar Aug 10 '20 17:08 pop-ch