[pmwiki-users] Highlight pagelist search results based on time thresholds

Hans design5 at softflow.co.uk
Sun Jul 13 06:46:00 CDT 2008


Sunday, July 13, 2008, 8:38:17 AM, stevecrisp at gmail.com wrote:

> I'd like to be able to highlight pagelist search results based on a
> series on time thresholds.

Here is my attempt. Similar to Peter's but with different format.
It should appear as solid blocks with background color, even though
each line is in its own div. But using divs i had no gaps between
lines (I tested with Triad skin).

I don't use (:if date ...:) but (:if lt unixtimes...:),
and you need http://www.pmwiki.org/wiki/Cookbook/MarkupExprPlus
installed for this to work.

Add to config.php:
//define some time page variables in unix time format
$FmtPV['$ModTime'] = '$page["time"]'; //last modified unix time
$FmtPV['$Now'] = '$GLOBALS["Now"]'; //$Now = unix time now = time()
$FmtPV['$WeekAgo'] = '$GLOBALS["Now"]-7*24*60*60'; //7 days
$FmtPV['$MonthAgo'] = '$GLOBALS["Now"]-30*24*60*60';  //month as 30 days

Add to your page, change group= as you need it:

>>width=70pct border='1px solid #ccc'<<
!!!Recent Articles
(:pagelist group=Test list=normal fmt=#colorblocks order=-time:)
>><<

(:if1 false:)
[[#colorblocks]]
(:if gt {=$ModTime} {$WeekAgo}:)
>>bgcolor=#fcc<<
(:elseif gt {=$ModTime} {$MonthAgo}:)
>>bgcolor=#fed<<
(:else:)
>>bgcolor=#eee<<
(:ifend:)
*[[{=$FullName}|+]] [- . . . . . by [[~{=$LastModifiedBy}]] on {=$LastModified}-]
(:template last:)
>><<
[[#colorblocksend]]
(:if1end:)

The #colorblocks pagelist template should best go into
Site.LocalTemplates.
The (:if1 false:) works only in latest 2.2 beta66 (nested ifs), i
just use it in the page for eaier testing.

the output includes 'modified by' and 'when' info like recent changes,
remove these from the template for your purpose.

I was surprised I could not use {(ftime ....)} in the pagelist
template, that's why I resorted to page variables and unix time
comparisons.

  ~Hans




More information about the pmwiki-users mailing list