[pmwiki-users] ZAPData -- Increment Page ID "stamp" in form submission

Sivakatirswami katir at hindu.org
Mon Dec 11 04:38:36 CST 2006


Now that we have thread numbering working..
I  see that it  will not serve our requirements.

Context: simple form that creates a page:

TODO-fooProjectGroup.(IDNumber)

The page might be something like  this:

TOD0-LandManagement.10001

containing:

(:comment data:)
(:Project: LandManagement:)
(:Owner: Katir:)
(:Priority: 2:)
(:Status: 1-Open:)
(:Description: Fix the pull on the Husky... still sticks:)

OK with the TODO from installed in Site.AllGroupHeader
It picks up and displays this data quite nicely...OK
Let's say we change the Owner to "Andre" and  the priority 1
And submit:

(:comment data:)
(:Project: LandManagement:)
(:Owner: Andre:)
(:Priority: 1:)
(:Status: 1-Open:)
(:Description: I can't fix it! Can you take it to Kawamura's shop?:)

now I get a new page:
TOD0-LandManagement.10002
with the above data..

So now we have 2 TODO's where only 1 is wanted.
We just  want the  original over --written with the updated data.

The model we need seems to be different. Somewhere on some
static datapage we maintain some permanent ID variable
e.g.  ProjectManagement.DataPage
has value (:ToDoID: 10000:)
This would start out as a single integer: 10000

And every time a form is submitted, from Site.AllGroupHeader.
it would get incremented. This is already being done in the
XToDo cookbook "Simple ToDo" recipe but I am unable to
expose the mark up to see how to do it.

The generalized algorithm is pretty simple and would look something like 
this
(excuse me if I mix in xTalk since I'm a long time Revolution coder...)

(: input hidden ToDoID
     if field "ToDoID" is empty then # it means  this is a brand new 
submission

      updateCounter ({$ToDoID}) # a function call to the data page which 
contains the counter

         value = ({$ToDoID} # where we get the newly updated value for 
this  input value

else
   # it means this is an existing data page
value = ($:ToDoID)
  # where the value already exists as the data
  # (:IToDoID: 10001:)  on the page

function upDateCounter ({$ToDoID})
   # increment the ($:ToDoID) value on ProjectManagement.DataPage by +1
end UpdateCounter

Submit:

The page name remains the same  ToDo-Landmanagement.10001
and is simply over written with the new values.. and  the
same TODO is updated.  OR If it is a new page, our ID  counter is 
incremented
by one and a new page is created:
ToDo-Landmanagement.10002

Ideas?

Om shanti

Sivakatirswami
www.himalayanacademy.com





More information about the pmwiki-users mailing list