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";
}
Peak memory: 1,493,400 bytes