bwanders / dokuwiki-strata

Strata - a Semi-Structured Data plugin for Dokuwiki
https://www.dokuwiki.org/plugin:strata
17 stars 8 forks source link

Suggestion: Include a query from another page #49

Open pop-ch opened 4 years ago

pop-ch commented 4 years ago

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.

bwanders commented 4 years ago

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)

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.

pop-ch commented 4 years ago

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.

bwanders commented 4 years ago

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

pop-ch commented 4 years ago

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