[pmwiki-users] Calendar / Event list

Patrick R. Michaud pmichaud at pobox.com
Fri Mar 31 08:34:48 CST 2006


On Fri, Mar 31, 2006 at 12:53:03PM +0200, Thomas Lederer wrote:
> I would like a page (one) to store the events. Having one page per event
> seems to be huge unnecessary waste.
> 
> My requirements are: 	date	time	description (less than 10 words)
> 
> thats basically one line per event.
> 
> I thought maybe something like this:
> 
> ||[[#t200604]]|| || ||
> ||[[#t20060401]]01.04.2006 ||20.00 || Pizzaeating ||
> ||[[#t20060404]]04.04.2006 ||      || Holiday     ||
> ||[[#t20060411]]11.04.2006 ||20.00 || Party-Time  ||
> ||[[#t20060419]]19.04.2006 ||15.00 || Teatime     ||
> ||[[#t200605]]|| || ||

Try a special-purpose markup variable.  First, you can see it
working at http://www.pmwiki.org/wiki/Test/NextEventAnchor .

The code to enable this is:

    $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";
    }

What this does is define a special purpose markup variable called
"{$NextEventAnchor}" that returns the first anchor of the page that 
comes on or after todays date (where anchors are formatted as 
"#tyyyymmdd").  Thus, if the "Events" page contains:

    ||[[#t20060330]]03.30.2006 ||08.00 || Lunch       ||
    ||April 2006 ||||||
    ||[[#t20060401]]01.04.2006 ||20.00 || Pizzaeating ||
    ||[[#t20060404]]04.04.2006 ||      || Holiday     ||
    ||[[#t20060411]]11.04.2006 ||20.00 || Party-Time  ||
    ||[[#t20060419]]19.04.2006 ||15.00 || Teatime     ||
    ||May 2006 ||||||

then {Events$NextEventAnchor} will return "Events#t20060401"
until April 1st, starting April 2nd it will return "Events#t20060404",
starting April 5th it will return "Events#t20060411", etc.

This page variable can then be used with (:include:), thus:

  - display the next event

        (:include {Events$NextEventAnchor}:) 

  - display the next three events

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


Pm





More information about the pmwiki-users mailing list