Compatible with DokuWiki
Similar to pagetemplater
Download and install the plugin using the Plugin Manager using the URL given above. Refer to Plugins on how to install plugins manually.
The plugin allows you to seperate the structure of a wiki page and the data contained within. This allows you to have multiple data pages referencing the same structure page. Technically, you can also combine several structure pages. I will continue to use the term “structure page” for the pages that contain dokuwiki code and placeholders for data and “data page” for those that contain the actual data that will be inserted into those placeholders. Both types of pages can be viewed when browsing the wiki. The structure page will be displayed as is, whereas the data page is displayed as the final compiled page, structure and all.
Please note that I wrote this plugin to solve a very specific problem so some of the functionality may not be generally useful. This is also my first dokuwiki plugin and I'm not very experienced with php, so this plugin very possibly contains security issues and bugs. I really appreciate any feedback.
All replacement commands look like the following: ~~COMMAND(x[,var]):param1[:param2[:param3]]~[!]~
Available Commands:
A sample for a list would be:
WIKISOFTWARE = ( 'DokuWiki', '2009-12-25', 'GPL 2' ),
( 'MediaWiki', '2010-04-07', 'GPL' )
Use in the template would then look like this:
^ Name ^ Last Release ^ License ^
~~LIST(0):WIKISOFTWARE:[| @0 | @1 | @2 | ]:5~~
As you can see, the first parameter (WIKISOFTWARE) names the list to display, the second one ([ @0 | @1 | @2 | ] specifies the structure of each row. The final parameter (5) is optional. If set, the table will contain at least that many rows. In the above case, 3 empty lines will be appended (5 minus the 2 lines of content). Of course the cells can contain further replacement commands:
~~LIST(0):SOMELIST:[| @0 | ~~IF(1):@1:YES:NO~~ | ]:5~~
Note that if the pass of these commands is less or equal to the pass of the list-command itself, they will be evaluated BEFORE the list is expanded, otherwise (like in the sample) they are expanded afterwards and will thus refer to the content of the row.
data is declared with simple key-value pairs, one per line: VARIABLENAME = VALUE
When declaring a variable for a LIST command, VALUE is a list of rows, where is row a is enclosed in regular brakets:
LIST = (5, true, "foo"),
(3, false, "bar")
Please note that rows after the first need to be indented for parsing to work.
All variable declarations need to be enclosed within the following tags [VARIABLES] [ENDVARIABLES]
Maps are declared either in the structure page or a seperate data page. In the simple case they are defined like this:
NAME = a, b, c, d, e,
f, g, h, i, j
In this case, this is a simple array, the index 0 will map to a, the index 2 to c and so on. Again, don't forget to indent rows after the first.
Alternatively, you can manually specify indices: NAME = 1 = a, 3 = b, 8 = c
This mainly makes sense if you intend to use LOOKRANGE for the lookup. There, 1 and 2 will map to “a”, 3,4,5,6 and 7 to “b” and everything else to “c”.
maps are declars within the tags [MAPS] [ENDMAPS]
finally, you must put together the data. Simply put this at the end of your data page: [INCLUDE:namespace:foo:template]
When the data page is displayed, everything between [VARIABLES] and [ENDVARIABLES] is evaluated but not printed. The INCLUDE will be replaced with the content of the interpreted template page and only that will be displayed. Of course you can have multiple includes and thus construct a page from multiple templates or you can include variable definitions from a separate page.