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.11 00.11 MarkupToHTML begin
 3: 00.11 00.11 MarkupToHTML begin
 4: 00.12 00.12 MarkupToHTML end
 5: 00.12 00.12 MarkupToHTML begin
 6: 00.12 00.12 MarkupToHTML end
 7: 00.12 00.12 MarkupToHTML begin
 8: 00.12 00.12 MarkupToHTML end
 9: 00.12 00.12 MarkupToHTML begin
10: 00.13 00.12 MarkupToHTML end
11: 00.13 00.12 MarkupToHTML begin
12: 00.13 00.12 MarkupToHTML end
13: 00.14 00.13 MarkupToHTML end
14: 00.14 00.13 MarkupToHTML begin
15: 00.15 00.14 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
16: 00.16 00.15 ReadApprovedUrls SiteAdmin.ApprovedUrls end
17: 00.16 00.15 MarkupToHTML end
18: 00.17 00.16 MarkupToHTML begin
19: 00.17 00.16 MarkupToHTML end
20: 00.18 00.16 now
Peak memory: 3,410,224 bytes