[pmwiki-users] Pagelists and PTV (updated)

Knut Alboldt pmwiki at alboldt.de
Wed Dec 21 16:22:18 CST 2011


Hi !

As Peter said: you have to write a short script - like this:

e.g. collect.incphp:
==============================
<?php

   $Collected = array();

/*
   (:collect key values:)

   in a pagelist template:


=== Page Test.Collect ===
(:pagelist name=Test.Collect-* fmt=#collect:)


----
:pagelist format:

  [@
[[#collect]]
(:template first:)
:collecting keys and values:
(:template each:)
* collecting: keys="{=$:years}" value="{=$Title}" (you can delete this)
(:collect keys="{=$:years}" value="{=$Title}":)
(:template last:)
:Output the result:
(:collected:)
[[#end]]
@]

=== Page Test.Collect01 (etc) ===

(:title Collect - 01:)

:years:1951, 1952, 1953

=== end ===
  */
Markup('collected','directives','/\(:collected:\)/e','Collected()');

Markup('collect','directives',
	'/\(:collect\s?+(.*):\)/e','Collect("$1")');

function Collected()
{
   global $Collected;
   $text = "";

   ksort($Collected);

   foreach ($Collected as $key => $values)
   {
     $text .= "* $key $values\n";
   }
   return PRR($text);
}
function Collect($args)
{
   global $Collected;

   $args = ParseArgs($args);

   $keys   = preg_split("/,/",$args['keys']);
   $value  = $args['value'];

   foreach ($keys as $key)
   {
     $key = trim($key);
     $Collected[$key] .= $value . " ";
     $debugtext .= "** DEBUG: $key: $value\n";
   }
}
?>

==============================

in your config-file include this file using:

	require_once("collect.incphp");


Should work.

Regards

Knut


Am 21.12.2011 10:30, schrieb Christian Moser:
> Hi everybody
>
> I wondered whether the following could be accomplished somehow.
>
> Let's assume I have two pages:
>
> (:title First:)
> (:ptv:1850, 1851, 1854:)
>
> and
>
> (:title Second:)
> (:ptv:1852, 1853, 1855:)
>
>
> Is there a way to have a pagelist output (with a local pagelist
> template) like this:
>
> 1850 First
> 1851 First
> 1852 Second
> 1853 Second
> 1854 First
> 1855 Second
>
> Many thanks in advance!
> Christian
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>



More information about the pmwiki-users mailing list