[pmwiki-users] Manipulating dates with MarkupExpressions & ZAP

The Editor editor at fast.st
Tue Jun 12 20:17:21 CDT 2007


On 6/9/07, Benoit Dutilleul <benoit.dutilleul at googlemail.com> wrote:
> I am working on a system to manage a list of events. Each event is defined
> by a title, a description, a date and a venue. I have problems to have the
> dates working properly. Indeed, my zap form asks the user adding the event
> for a year, a month, a day and an hour but I want all this information to be
> converted into a timestamp.
>
> This is how I am trying to do it - without success - for the moment:
>
> (:zapform key=AddEvent:)
> (:zap datapage="Events.Event-{(ftime %s)}" AddEvent:)
> (:input text EventYear "{$thisyear}":)
> (:zap EventDate={(ftime fmt='%s' when='{$EventYear}')} AddEvent:)
> (:zap savedata="EventDate" AddEvent:)
> (:input submit:)
> (:zapend:)
>

Benoit, this won't work as you intend because you have an order of
operation problem.  The ftime function in EventDate is rendered when
the page loads, at which time $EventYear has no value.

Also remember, to insert EventYear into EventDate you must use field
replacement syntax, ie {EventYear}, not {$EventYear}. But again, the
markup expression is rendered when the page loads, and field
replacements only after the form is submitted. Too late.

You could try using a line like this instead:

(:zap php_EventDate="strtotime|{EventYear}" AddEvent:)

This pulls in the text they enter, and tries to convert it to a
timestamp. Not tested.

Cheers,
Dan



More information about the pmwiki-users mailing list