[pmwiki-users] Problem using MarkupExpressions with ZAP variable

Patrick R. Michaud pmichaud at pobox.com
Sun Jun 17 14:31:59 CDT 2007


On Sun, Jun 17, 2007 at 03:08:51PM -0400, The Editor wrote:
> On 6/17/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> >On Sun, Jun 17, 2007 at 08:55:55AM -0400, The Editor wrote:
> >>
> >> I still don't like all the changes Pm made to the time function,
> >> specifically to require the @ symbol, but that's how it works in
> >> PmWiki.
> >
> >I felt this was important so that we could reliably distinguish
> >ISO dates (20070617) from UNIX timestamps (@20070617).  
> 
> Perhaps the problem has
> to do with the lack of documentation. Not sure where to put it though
> as it's not really a ZAP function any longer.

Since ZAP is providing the interface to strtotime(), I think that's 
probably a good place to mention the use of @ when using the results
of strtotime with {(ftime)}.

PmWiki itself doesn't expose timestamps to authors, but instead tries
to stick with ISO formats (which have the advantage of being readable
and meaningful to most authors).

And, of course, {(ftime)} will accept any format that strtotime()
accepts, so instead of calling strtotime in the zap form and
storing the result, one could instead just store the human-readable
value directly, and avoid the conversion to a timestamp altogether.  
Thus, instead of:

>  (:zapform key=AddEvent:)
>  (:input text EventYear:)
>  (:zap php_EventDate="strtotime|{EventYear}" AddEvent:)
>  (:zap EventDate="{php_EventDate}" AddEvent:)
>  (:zap savedata="EventDate" AddEvent:)
>  (:input submit:)
>  (:zapend:)
>
>  {(ftime %Y when="{$:EventDate}":)

I would think that one could more easily do something like:

   (:zapform key=AddEvent:)
   (:input text EventYear:)
   (:zap EventDate="{EventYear}" AddEvent:)
   (:zap savedata="EventDate" AddEvent:)
   (:input submit:)
   (:zapend:)
 
   {(ftime %Y when="{$:EventDate}":)

In fact, it seems that one could just save EventYear directly
to the page, and use it directly:

   {(ftime %Y when="{$:EventYear}":)

Pm



More information about the pmwiki-users mailing list