[pmwiki-users] how to pass values to edit template?
Petko Yotov
5ko at free.fr
Sat Mar 10 13:07:57 CST 2007
On Saturday 10 March 2007 19:18, SteP wrote:
> Is the {field} markup native of PmWiki, or something that Petko's
> newmessageboxplus added? If the latter, then it's available only when
Yes, it is in the recipe only.
> (:input action new:) is used, correct?
Correct. You mean (:input hidden action new:)
> I was hoping that there would be a
> generic way to pass variables to a page which the page could then read and
> store. (This is an extension of the question in my OP.)
It may be done by copying the $_REQUEST array into PageVariables[1], then
using a function similar to ReplaceOnEdit[2].
I can only recommend if someone starts implementing that, to use a single
prefix of the page variables, i.e. {$REQ_field}.
[1] http://www.pmwiki.org/wiki/PmWiki/PageVariables
[2] http://www.pmwiki.org/wiki/Cookbook/ROEPatterns
>
> I have two specific applications in mind:
> 1. toggle a state page variable
> 2. store an array of selected pages
>
> I still have no clue how to achieve #1. My page includes
> (:state:0:)
> and I would like an interactive way to toggle {$:state} and save its new
> value in the same page. I looked at fox (amazing!), but it seems to me it
> mostly provides functions for adding/removing text inside pagess, not for
> replacing a stored value.
This cannot be done with NewPageBoxPlus.
With AddDeleteLine2 and very probably with FOX you can very easily ADD a
string like "(:state:1:)" and also easily REMOVE such a string. That way, the
{*$:state} page text variable will be empty or not empty and you can use it
in pagelists, conditionals or sorting, or whatever.
>
> As for #2, I think I need to use a pagelist with a fmt that includes
> (:input checkbox[] :) but then I'm not sure how to get that checkbox value
> out of the form and into a page.
This is possible with the modified version of NewPageBoxPlus, but you need to
learn how to use pagelists and forms.
Here is what I use for a simple contacts manager (inside a form similar to
what I posted earlier):
(:pagelist trail=Contacts.Categories fmt=#cat2:)
The format, bottom of the same page:
[@
[[#cat2]]
(:input checkbox "cats[]" "[[{=$Name}]]":) {=$Name}\\
[[#cat2end]]
@]
The page Contacts.Categories contains a bulleted list of categories (pages)
like this:
* [[Family]]
* [[School]]
* [[Work]] etc.
And in the template, the string {cats} will expand to the imploded list of the
checked categories (i.e. "[[School]], [[Work]]").
Yes, there is a problem with PmWiki, it allows you to achieve everything but
you have to deal with a lot of information overload...
Good luck!
Petko
More information about the pmwiki-users
mailing list