[pmwiki-users] Fwd: pagelist of referenced items
Markus Heinzer
keusen at gmail.com
Mon Aug 16 09:59:40 CDT 2010
Thanks Peter
I took your second solution (the one with the Markup) since to my eyes
this is more pmwiki-style than the wikish-thing. Anyway both solutions
look fine.
Finally I got it working. And I even added some titles to the topic
areas. Thanks for your hints, I learned a lot.
------------ code into config.php ---------------
Markup("loop-de-loop", "<pagelist", "/\\(::loop-de-loop (.*?)::\\)/e",
"NestedLoopEcho('$1')");
function NestedLoopEcho($arg)
{
$arg = stripslashes(str_replace('\n', "{newline}", $arg));
$topics = array('Birds','Fish','Dinosaurs','Insects','Mammals');
$opt = array('start1'=>1, 'end1'=>5, 'start2'=>1, 'end2'=>200);
$opt = array_merge($opt, ParseArgs($arg));
$rtn = "";
for ($i = $opt['start1']; $i <= $opt['end1']; $i++)
{
if ($opt['fmt1'])
{
$rtn .= str_replace(array('{loop1}', '{loop2}',
'{newline}'), array($topics[$i-1], $j, "\n"), $opt['fmt1']);
}
for ($j = $opt['start2']; $j <= $opt['end2']; $j++)
{
if ($opt['fmt2'])
{
$rtn .= str_replace(array('{loop1}', '{loop2}',
'{newline}'), array($i, $j, "\n"), $opt['fmt2']);
if ($opt['fmt3'])
{
$rtn .= str_replace(array('{loop1}', '{loop2}',
'{newline}'), array($i, $j, "\n"), $opt['fmt3']);
}
}
}
}
return $rtn;
}
--------------------------------------------------------------
-------------- code onto pagelist-page ---------------------
(::loop-de-loop start1=1 end1=2 start2=120 end2=130
fmt1="{newline}!!!Topic area: {loop1}" fmt2="{newline}Question {loop2}:
" fmt3='(:pagelist "[[#answer-{loop1}-{loop2}]]" order=title
loop1={loop1} loop2={loop2} fmt=#listansweringpages:)'::)
---------------------------------------------------------------------------
don't forget to put this all on one line. One can adapt the values
start1/end1 and start2/end2 to one's needs.
Markus
More information about the pmwiki-users
mailing list