Search code examples
dokuwiki

Dokuwiki - how to change visible page contents dynamically


I have some developer documentation on a dokuwiki site. There are multiple versions of the software (e.g. v1, v2...). I would like to be able to dynamically change the visible contents of the page based on the version of the software.

For instance, maybe there's a dropdown on the page that allows the reader to select "v1, v2, etc." When v2 is selected only certain parts of the page change to reflect the v2 part of this.

Here's an example of some wiki page contents:

To build the foobar project, first download the code:
  cd ~
  git clone https://foo.example.com/bar.git
  git checkout v1.0

  ...

If the person changed the selected item in the dropdown to v2 it would change to the following:

To build the foobar project, first download the code:
  cd ~
  git clone https://foo.example.com/bar.git
  git checkout v2.0

  ...

Does anyone know of a plugin that can do this sort of thing in Dokuwiki?


Solution

  • I wrote the variants plugin some time ago, it is a proof of concept of a plugin that makes it possible to provide variants of parts of a page depending on user-provided parameters. It works, but the feature set is very limited, i.e. you can only specify some parameter in the URL and then depending on that parameter you can have if-else-blocks in your text. It should be possible to set that parameter from a dropdown, but the plugin does not provide a dropdown. If you want to extend it feel free to do so and please send a patch or pull request.

    Another approach is used by the page4release plugin which has been built for the purpose you describe but it uses completely different pages for different versions of the software. You could also use a combination of this plugin and the include plugin if your pages have large common parts that you could include from one common page (disclaimer: I'm the author of the include plugin).