[pmwiki-users] making pagelist template produce a cell, not a table

Patrick R. Michaud pmichaud at pobox.com
Fri Jan 19 07:55:49 CST 2007


On Fri, Jan 19, 2007 at 01:12:14PM +0100, Jean-Fabrice [gmail] wrote:
> 2007/1/19, The Editor <editor at fast.st>:
> Here is exactly what I want to do :
> (:table:)
> (:cellnr:)head1
> (:cell:)head2
> (:cell:)head3
> (cellnr:)data from aGroup
> (:pagelist Group=aGroup fmt=#myFmt trapvalue:)
> (:cellnr:)data from anotherGroup
> (:pagelist Group=anotherGroup fmt=#myFmt trapvalue:)
> (:cellnr:)data from athirdGroup
> (:pagelist Group=athirdGroup fmt=#myFmt trapvalue:)
> (:tableend:)
> 
> and define #myFmt to be :
> (:cell:)pagetextvar1
> (:cell:)pagetextvar2
> (:cell:)pagetextvar3
> 
> i.e :
> Each searched group contains only one page with 'trapvalue' in it
> Each of this page have the same form (i.e the same pagetextvar)

You can do the whole thing with a single pagelist template:

[[#myFmt]]
(:if equal {<$Group}:)
(:table:)
(:cellnr:)head1
(:cell:)head2
(:cell:)head3
(:if ! equal {<$Group} {=$Group}:)
(:cellnr:)data from {=$Group}
(:if:)
(:cellnr:)pagetextvar1
(:cell:)pagetextvar2
(:cell:)pagetextvar3
(:if equal {$>Group}:)(:tableend:)
[[#myFmtend]]

Then, your pagelist command for the entire table becomes:

(:pagelist group=aGroup,anotherGroup,athirdGroup fmt=#myFmt trapvalue:)

Some notes/explanation:

- The first (:if equal {<$Group}:)  block generates the table and 
  headings at the beginning of the first record in the list
- The second (:if !equal {<$Group} {=$Group}:) block generates a 
  table row to mark the beginning of each group
- The third (:if:) block generates a table row for each found page
- The last (:if equal {>$Group}:) block ends the table when the 
  last record is finished

Also, FWIW, PmWiki doesn't require a (:table:) directive to
start a new table (the directive is required to set options, however).

Pm




More information about the pmwiki-users mailing list