[pmwiki-users] Sign-up sheet

Hans design5 at softflow.co.uk
Sun Sep 27 04:17:26 CDT 2009

Friday, September 25, 2009, 1:39:55 AM, Gary Spivey wrote:

> I want to create a sign-up sheet using PmWiki. I want to display a table,
> and have folks able to enter their usernames in the table where open spots
> exist. When they enter their name, the system should replace the open spot
> with their name. It would certainly be great if they can delete their name
> as well. Tying the name entry and delete to some authentication scheme would
> also be nice. 

Hi Gary,
there is no custom recipe for this, but one solution is by
building a table using (:table:) markup, then using a PTV inside each
cell with a unique name, and using Cookbook/Fox and Cookbook/FoxEdit
to add a foxedit link to each cell, which will call a custom fox edit
form to add or remove the logged in user. To get the authentication
you require, use Pmwiki/AuthUser and assign userid and password to
each user.

So you need to install:

Then you need to add a custom conditional 'authuser' for checking the AuthId:
add to config:
$Conditions['authuser'] = '\$GLOBALS["AuthId"]==\$condparm';

Here is an example SignUpSheet page, showing the table structure,
and for each cell a hidden PTV followed by a var to show its content,
a foxedit link inside a conditional to show the edit link only for
the logged in user or any user if the PTV is empty, plus some wiki
inline styling to make the edit link appear to the right top corner
and small.

Each foxedit link looks like: {[foxedit A1 form=SignUpForm]}
Here 'A1' is the name of the PTV to be edited. So each link uses a
different value to edit a different PTV.
It could be followed by a link label, leaving it out uses the default
'Edit' as link text.
The form=SignUpForm will call a Fox form on page 'SignUpForm', which
is used to edit the PTV. Modify this value in all edit links
if the form is on a different page.

This table has 5 columns and 2 rows, so you want to modify this.
You may wish to modify the PTV names, although they are hidden.
Just make sure that for each cell the PTV name reference is used in
all instances in the conditional and foxedit link!

SignUpSheet page content:
Hello {$AuthId}
(:table border=1:)
(:A1: :){$:A1} \
(:if expr authuser {$:A1} || ( ( equal {$:A1} '' ) && authid ):)\
%right%[-'^{[foxedit A1 form=SignUpForm]}^'-](:if:)
(:A2: :){$:A2} \
(:if expr authuser {$:A2} || ( ( equal {$:A2} '' ) && authid ):)\
%right%[-'^{[foxedit A2 form=SignUpForm]}^'-](:if:) 
(:A3: :){$:A3} \
(:if expr authuser {$:A3} || ( ( equal {$:A3} '' ) && authid ):)\
%right%[-'^{[foxedit A3 form=SignUpForm]}^'-](:if:) 
(:A4: :){$:A4} \
(:if expr authuser {$:A4} || ( ( equal {$:A4} '' ) && authid ):)\
%right%[-'^{[foxedit A4 form=SignUpForm]}^'-](:if:)
(:A5: :){$:A5} \
(:if expr authuser {$:A5} || ( ( equal {$:A5} '' ) && authid ):)\
%right%[-'^{[foxedit A5 form=SignUpForm]}^'-](:if:)
(:B1: :){$:B1} \
(:if expr authuser {$:B1} || ( ( equal {$:B1} '' ) && authid ):)\
%right%[-'^{[foxedit B1 form=SignUpForm]}^'-](:if:)
(:B2: :){$:B2} \
(:if expr authuser {$:B2} || ( ( equal {$:B2} '' ) && authid ):)\
%right%[-'^{[foxedit B2 form=SignUpForm]}^'-](:if:)
(:B3: :){$:B3} \
(:if expr authuser {$:B3} || ( ( equal {$:B3} '' ) && authid ):)\
%right%[-'^{[foxedit B3 form=SignUpForm]}^'-](:if:)
(:B4: :){$:B4} \
(:if expr authuser {$:B4} || ( ( equal {$:B4} '' ) && authid ):)\
%right%[-'^{[foxedit B4 form=SignUpForm]}^'-](:if:)
(:B5: :){$:B5} \
(:if expr authuser {$:B5} || ( ( equal {$:B5} '' ) && authid ):)\
%right%[-'^{[foxedit B5 form=SignUpForm]}^'-](:if:)

And here is the custom Fox edit form, on page SignUpForm, which gets
called by each foxedit link in above table:

SignUpForm page content:
(:fox signupform  ptvtarget={$EditTarget} ptvfields={$EditSection} redirect=1 :)
(:input hidden csum 'Field {$EditSection} edited':)
(:if equal {{$EditSource}$:{$EditSection}} {$AuthId}:)
Remove '''{$AuthId}''' from Field {$EditSection} 
(:input hidden name=$:{$EditSection} value='NULL':)\\
  (:input submit post 'Remove':)   (:input submit cancel 'Cancel':)
Sign up '''{$AuthId}''' for Field {$EditSection}
(:input hidden name=$:{$EditSection} value='{$AuthId}' checked:)\\
  (:input submit post 'Sign up':)   (:input submit cancel 'Cancel':)
(:foxend signupform:)

This form will show either a 'sign up' button or a 'remove' buttton
(plus a 'Cancel' button), depending if the user was signed up already
(via the (:if equal ... :) conditional).
Once clicked, it takes the user back to the SignUpSheet.

The page variables in the form {$EditTarget},{$EditSource},{$EditSection}
are constructed by FoxEdit and refer to the calling page = {$EditSource},
the part to edit = {$EditSection} (in this case it is a single named
PTV), the target = {$EditTarget}, which is the same here as
{$AuthId} is the user name as logged in, which is constructed by

I am sorry there is a fair bit of code in these pages!
But using the page is very simple as a consequence.
I am happy to explain any aspects of the coding and markup used
in the example. I have tested it, so it is a working example.
I will add it as a Fox application example to the Cookbook.


More information about the pmwiki-users mailing list