NextEventAnchor


Events are held on the Events page.

The next event is: Test.Events#noevent

Problem with headings in the middle being shown:

(:include Events#t20060419# lines=4:)
19.04.200615.00Teatime
May 2006
01.05.200620.00Pizzaeating
04.05.2006 Holiday

Even with display=none there is a small (invisible without tableborders) line.

%define=monat display=none%
(:include Events#t20060419# lines=4:)
19.04.200615.00Teatime
May 2006
01.05.200620.00Pizzaeating
04.05.2006 Holiday

Find the next event:

(:include {Events$NextEventAnchor} :)

Print the remaining calendar:

(:include {Events$NextEventAnchor}# :)

Print only the next three events:

(:include {Events$NextEventAnchor}# lines=3:)

Here's the code for the {$NextEventAnchor} page variable:

$FmtPV['$NextEventAnchor'] = 'NextEventAnchor($pn)';

function NextEventAnchor($pagename) {
  global $Now;
  $npat = '[[:alpha:]][-\\w]*';
  $page = RetrieveAuthPage($pagename, 'read', false, READPAGE_CURRENT);

  $todayanchor = strftime('#t%Y%m%d', $Now);
  if ($page
      && preg_match_all("/\\[\\[(#$npat)\\]\\]/", $page['text'], $alist)) {
    foreach($alist[1] as $a)
      if ($a >= $todayanchor) { return "$pagename$a"; }
  }
  return "$pagename#noevent";
}
 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.21 00.20 MarkupToHTML begin
 3: 00.21 00.20 MarkupToHTML begin
 4: 00.22 00.21 MarkupToHTML end
 5: 00.22 00.21 MarkupToHTML begin
 6: 00.22 00.21 MarkupToHTML end
 7: 00.22 00.21 MarkupToHTML begin
 8: 00.22 00.21 MarkupToHTML end
 9: 00.22 00.21 MarkupToHTML begin
10: 00.22 00.21 MarkupToHTML end
11: 00.22 00.21 MarkupToHTML begin
12: 00.22 00.21 MarkupToHTML end
13: 00.23 00.22 MarkupToHTML end
14: 00.23 00.22 MarkupToHTML begin
15: 00.24 00.23 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
16: 00.24 00.23 ReadApprovedUrls SiteAdmin.ApprovedUrls end
17: 00.25 00.24 MarkupToHTML end
18: 00.25 00.24 MarkupToHTML begin
19: 00.25 00.24 MarkupToHTML end
20: 00.26 00.24 now
Peak memory: 3,732,424 bytes