[pmwiki-users] Pagelists of multiple linkbacks

Hans design5 at softflow.co.uk
Mon Aug 11 09:55:30 CDT 2008

Peter just mailed me and suggested that my markup expression solution
should output a comma-separated list of page names, which can be
given as value to a pagelist name= parameter, and any custom
formatting can be applied.

I like this idea of separating formatting (and ordering) from
creating a unified pagelist, so here is another modified markup
expression for this, which I may well add to the PowerTools script:

# return united pagelist formatted as simple list
# from csv-pagelists supplied as arguments
$MarkupExpr['unilist'] = 'MxUniList($pagename, $args, $argp)';
function MxUniList($pagename, $args, $opt) {
        $a = array();
        foreach($args as $v) {
                $vv = explode(',',$v);
                $a = array_merge($a, $vv);
        $a = array_unique($a);
        $sep = (isset($opt['sep'])) ? $opt['sep'] : ',';
        $sep = str_replace('\n',"\n",$sep);
        foreach ($a as $i => $p)
                $a[$i] = @$opt['pre'].$p.@$opt['suf'];
        return implode($sep,$a);

Then one can use in a page this markup (on one line!) for instance:

(:pagelist fmt=#title name=(unilist (pagelist link=Category.A)
   (pagelist link=Category.B)):)

The above 'unilist' markup expression allows for setting of an item
separator with the sep=  parameter, and setting of an item prefix with
pre= parameter, and an item suffix with suf= parameter. This makes it
possible to specify simple formatting, for instance a list by title
could be created with (on one line):

{(unilist (pagelist link=Category.A) (pagelist link=Category.B)
  sep=\n pre=*[[ suf=|+]] )}

i.e. each page name of the list is wrapped like *[[FullPageName|+]]
and a newline character is used as separator to create each list item
on its own line.


More information about the pmwiki-users mailing list