Forms-PTV
Writing PTVs can be done in a manner very similar to that seen in Forms-Logging. (If you haven't read that page, please do so before continuing here.)
Instead of writing at the beginning or end of a page you will write to a variable.
Your wikish script would contain some code that looks like this:
(...uninteresting stuff, including possible validation) echo "${name}" >Mygroup.Datapage$:name echo "${favorite}" >Mygroup.Datapage$:color echo "`ftime`" >Mygroup.Datapage$:time (uninteresting stuff...)
Now if you go to look at Mygroup.Datapage you will see something like this (looking at the source):
(:name:Sam:) (:color:chartreuse:) (:time:June 23, 2009, at 11:27:)
If you prefer a text-definition style PTV as opposed to the hidden PTV you could do this:
(...uninteresting stuff, including possible validation) echo "${name}" >Mygroup.Datapage$::name echo "${favorite}" >Mygroup.Datapage$::color echo "`ftime`" >Mygroup.Datapage$::time (uninteresting stuff...)
Now if you go to look at Mygroup.Datapage you will see something like this (looking at the source):
:name:Sam :color:chartreuse :time:June 23, 2009, at 11:27
In either case (both kinds of PTV) this information can be accessed from anywhere in pmwiki using {Mygroup.Datapage$:name}
, {Mygroup.Datapage$:color}
, and {Mygroup.Datapage$:time}
.
Of course, the difficulty with this is that each time someone submits more data it will overwrite the existing data. We could solve that problem by either (1) saving each person's vote in a different page (See Forms-CreatePages (especially at the end) or (2) changing the name of the variables for each person. More on this later.
Another related piece of functionality would be to save information into a section. WikiSh does that like this:
(...uninteresting stuff, including possible validation) echo "${name}" >Mygroup.Datapage#name echo "${favorite}" >Mygroup.Datapage#color echo "`ftime`" >Mygroup.Datapage#time (uninteresting stuff...)
Now if you go to look at Mygroup.Datapage you will see something like this (looking at the source):
[[#name]]Sam[[#nameEnd]] [[#color]]chartreuse[[#colorEnd]] [[#time]]June 23, 2009, at 11:27[[#timeEnd]]
Of course that seems a little senseless, but it makes a lot better sense if you start getting into fields with multiple lines that you want to put into a page. Later if you wanted to include this information onto a page you would use (:include Mygroup.Datapage#name:)
or the equivalent (if you wanted to use WikiSh you could do the same with {(cat Mygroup.Datapage#name)}
).