On Sun, Jul 13, 2008 at 1:46 PM, Hans <[EMAIL PROTECTED]> wrote:
> I was surprised I could not use {(ftime ....)} in the pagelist
> template, that's why I resorted to page variables and unix time
> comparisons.

Yes, I banged my head against the {(ftime ...)} for an hour or more
this morning before giving up and going the FmtPV route (which
presumably is faster anyway).  I revisited ftime just now and it
worked first time -- I think I must have been doing something strange
with my date formats before or something.

Here is the custom fmt def using ftime:

===(snip)===
!!!fmt=#ColorByDate2

A simple bullet list of page names. Colored %red%red%% if within last
7 days, %blue%blue%% if within last 30 days, %green%green%% if older.

[@
[[#ColorByDate2]]
* (:if date {(ftime "%Y-%m-%d" "-7 days")}..{(ftime "%Y-%m-%d")}
{(ftime "%Y-%m-%d" "{=$LastModifiedYMD}")}:)%red%(:elseif date {(ftime
"%Y-%m-%d" "-30 days")}..{(ftime "%Y-%m-%d")} {(ftime "%Y-%m-%d"
@{=$LastModifiedU})}:)%blue%(:else:)%green%(:ifend:) [[{=$FullName}]]
{=$LastModified}%%
[[#ColorByDate2end]]
@]
===(snip)===

You'll note I use {=$LastModifiedYMD} in one place and
@{=$LastModifiedU} in the 2nd place - I was just trying to figure out
where I went bad before. I think my problem was missing the @ sign in
front of the unix time before or maybe I was just trying to use
{$LastModified} straight (which seems impalatable to ftime).  The YMD
is as expected and the U is simply unix time ($page['time']).  Anyway,
here's a (presumably slightly slower) version which does not rely
quite so heavily on config.php customization (a single date variable
needs to be added instead of 3 or 4 of them).

(The block formatting is far superior - this is just to demonstrate
the ftime side of things.)

-Peter

_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to