[Pmwiki-users] Help with DTIndex

Philippe Krait philippe
Tue Oct 19 12:16:35 CDT 2004


Hello,

As advised,  have made the move to pmwiki 2. Everything works fine, 
except for one Cookbook recipe that I used extensively before, the 
DTIndex one.

It did not work at all, so I had to do heavy customisation (with my 
rather poor php skills) to make it do "sort of" what I want (I have 
also, I think, simplified it a bit by using a pmwiki function for 
lisiting pages, although how the $pat works in the ls function is beyond 
me :).

In the end, it does not look too bad, expect for one thing: It pops at 
the top of a menu instead at at the place where I have put the markup 
(which I have modified to give it a Pmwiki 2 look).

It probably has to do with the priority for the markup, but frankly I am 
at my wit's end here.

In case someone feels like helpinh, here is the page, I would like the 
list of pages to be at the bottom of the menu bar on the left, instead 
of at the top:  
http://newgallo.dnsalias.net/pmwiki/pmwiki.php/Adventures/HomePage

And here is the code for the DTIndex, after heavy modification:

<?php

/*
    Copyright 2003 Darren Turland.

    This script provides an Index of pages for PmWiki. Similar to $search
    without any arguments.  Layout is different.

    A B C D E ....  X Y Z
    A
      AllPages.. (PmWiki)
    B
    C
    D
      DarrenPage (Darren)
    etc..

    include_once("local/DTIndex.php"); in local.php

    then add [[$Index]] where-ever you require Index of all pages.

*/

Markup('Indexgroup','links', '/\\[:Indexgroup:\\]/e', 
"DTIndexAll('group')");
Markup('Index',     'links', '/\\[:Index:\\]/e',      "DTIndexAll('')");



# SDV($InlineReplacements['/\\[\\[\\$Indexgroup\\]\\]/e'], 
"DTIndexAll('group')");
# SDV($InlineReplacements['/\\[\\[\\$Index\\]\\]/e'], "DTIndexAll('')");

function DTIndexAll($group)
{
  global $WikiLibDirs;
  $ignore_pages = array('GroupAttributes','GroupHeader','GroupFooter',
                        'StartPagina','RecentChanges','Index','Log',
                        'PageFooter','PageHeader','SearchWiki',
                        'AttachementsLoaded','RecentUploads');

  if ( $group ) {
   global $pagename;
   $group=FmtPageName('$Group', $pagename);
  }

  #Remove the comments if you want all characters in the index
  #for($l_loop=65;$l_loop<65+26;$l_loop++)
  #  $DTIndexArray[chr($l_loop)] = "";

  $List = ListPages();
  foreach ($List as $pagefile) {
      # echo $pagefile."\n";
    $d1=FmtPageName('$Group',$pagefile);
    if ($d1 && ! ($group && ($group != $d1))) {
        $l_title = FmtPageName('$Title',$pagefile);
           if ( !in_array( $l_title, $ignore_pages ) ) {
               $l_key = substr($l_title,0, 1);
            $pagef = array();
               # $pagef['Title'] = FmtPageName('$Titlespaced',$pagefile);
               $pagef['Title'] = FmtPageName('$Title',$pagefile);
               if ( ! $group ) {
                 $pagef['Group'] = FmtPageName('$Group',$pagefile);
            }
            $pagef['Url'] = FmtPageName('$PageUrl',$pagefile);
            $DTIndexArray[$l_key][] = $pagef;
        }
    }
  }
  DTIndexShow($DTIndexArray);
}

function DTIndexShow($DTIndexArray)
{
  if (!$DTIndexArray) return;
  print "<table width=90%><tr><th colspan=3>";
#  print "<font size='+1'>";
  ksort($DTIndexArray,SORT_STRING );
#  foreach(array_keys($DTIndexArray) as $fred) {
#      print "<a href=\"#$fred\" >$fred</a>&nbsp;&nbsp;";
#  }
#  print "</font>";
  print "<tr>";
#  $length=ceil(count($DTIndexArray)/3);
  $length=ceil(count($DTIndexArray));
  $row=$length;
  foreach(array_keys($DTIndexArray) as $fred) {
    if ( $row >= $length  ) {
      print "<td valign=top>";
      $row=0;
    }
    $row++;
    if (is_array($DTIndexArray[$fred])) {
      print "<br /><a name=\"$fred\" id=\"$fred\"></a>";
      print "<strong><font size='+1'>$fred</font></strong>";
      sort($DTIndexArray[$fred['Title']]);
      foreach($DTIndexArray[$fred] as $item) {
        print "<br />&nbsp;&nbsp;  " ;
        print "<a href=\"";
        print $item['Url'];
        print "\" >";
        print $item['Title'];
        print "</a>";
    # if ($item['Group']) {
    #       print " ( ";
    #       print $item['Group'];
    #       print " )";
    # }
      }
    }
  }
 print "</table>";
}

?>

Thanks in advance,

Philippe




More information about the pmwiki-users mailing list