Currently pages with Data Forms can only reasonably be used with the ListPages module. When a Data Forms page is [[include]]ed it renders as a series of plain text fields which cannot be selected or formatted.
title: 'A Novel'
author: 'Joe Smith'
review: "A rather good book"
How-about a new piece of wikidot syntax which takes this format and uses it to set page variables:
[[with]]
[[include books:a-novel]]
[[do]]
{$title} by {$author}
[[/with]]
Note that it would have to treat single and double quotes the same way as %%form-data{xxx}%% does.
This would give use a lot more functionality:
- We could use [[include]] in places where we would otherwise need to nest ListPages.
- It reduces stress on the Wikidot servers: [[include]] is cheaper than [[module ListPages]].
- It is more general-purpose. You can put more complexity into multiple [[include]]s than a single level of [[module ListPages]].
- We could use it without an include to define default variable values without needing a second level of [[include]].
- We could use it with an include to select between sets of variable values
[[with]]
[[include vars:{$variable-set}]]
[[do]]
...rest of page...
[[/with]]
- Because it does not use ListPages, it will allow more powerful CSI features to be developed.
Use Cases
- You have a database of books as above, which use Data Forms. Each user has a page where they list the books that they own. That page can use ListPages to extract the data from the book database. Now suppose you want to produce a summary page. You use ListPages to aggregate the users' pages, but now the ListPages within them stop working.
- You have a gaming forum where you want to have some extended profile information such as callsign, team affiliation or highscores. You can make a data form page to hold that information, but in most of the pages where you want to display it, it is already inside a ListPages.
- You have a recipe database that you want to reference in your blog. The front page of the blog is implemented with ListPages.
- You have a database of books and a database of biographies. You want to do a database join: given a book, display the biography of the author.
Implementation
After variables have been replaced and [[include]]s have been actioned, all [[with]] blocks are parsed. This is treated similarly to an [[include]]. The variables defined before [[do]] are expanded in the text after [[do]], taking into account those variables defined with single and double quotes. Like with [[include]], this variable expansion may result in new syntax blocks becoming executable. It should not matter if the text is parsed twice, since there are simple workarounds to avoid executing blocks before the variables are expanded.