[Pmwiki-users] Some issues with the latest pmwiki release

Patrick R. Michaud pmichaud at sci.tamucc.edu
Tue Apr 29 06:45:35 CDT 2003

On 29 Apr 2003, John Rankin wrote:

> Pm writes:
>> Actually, I'm looking for a more general solution than the ones listed
>> above--I'm trying to figure out a way to control the order of items in
>> the LinkPatterns array.  I have a few ideas, but nothing leaps out at me
>> yet.  I'll probably solve it later tonight or tomorrow sometime.
> --
> I thought about that. The best idea I came up with was that you don't 
> actually have to control the order of all items, just the exceptions. 
> So I thought of an array that basically says 'evaluate this pattern 
> after this one', eg

Actually, another possibility is to make $LinkPattern into a 2 dimensional
sparse array where the first index indicates the sequence number of the
pattern.  PmWiki would store LinkPatterns similar to the following:

  $LinkPatterns[10]["\\bmailto:($UrlPathPattern)"] = "<a href='$0'>$1</a>";
  $LinkPatterns[20]["\\b($UrlMethodPattern):($UrlPathPattern)"] = $FmtUrlLink;
  foreach($InterMapFiles as $mapfile) {
    if (@!($mapfd=fopen($mapfile,"r"))) continue;
    while ($mapline=fgets($mapfd,1024)) {
      if (preg_match("/^\\s*\$/",$mapline)) continue;
      list($mapid,$mapurl) = preg_split("/\\s+/",$mapline);
      $LinkPatterns[30]["\\b$mapid:($UrlPathPattern)"] = $FmtUrlLink;
      $InterMapUrls[$mapid] = $mapurl;
  $LinkPatterns[40]["\\b($GroupNamePattern([\\/.]))?($FreeLinkPattern)"]  = 
  $LinkPatterns[50][$FreeLinkPattern]  = $FmtWikiLink;
  $LinkPatterns[60]["\\b$GroupNamePattern([\\/.])$WikiWordPattern"] =  
  $LinkPatterns[70][$WikiWordPattern] = $FmtWikiLink;

The number in the first brackets indicates the sequence order of the
pattern.  Thus, to add the PageTitle pattern that you're wanting, you could
add the following to local.php:

  $LinkPatterns[65]["\\$GroupNamePattern([\\/.])$PageTitlePattern"] =

The 65 would cause this pattern to be inserted after the Group/WikiWord 
pattern (60) but before the WikiWord pattern (70).  The actual numbers
used are unimportant--they simply specify the ordering of the patterns.
This seems like a fairly generic mechanism to provide control of the 
LinkPatterns array without being too difficult to implement or explain.

Comments, questions?  I'll want to hear comments in favor of or against
this approach before continuing towards an implementation (which should
be fairly easy).


More information about the pmwiki-users mailing list