[Pmwiki-users] Feature request?

J. Perkins jason
Sun Nov 16 19:33:27 CST 2003


I finally got around to trying this, and while it didn't work as 
suggested, it did show me how to do it. Here's the working solution, 
which I will add to the Cookbook as soon as I get a chance:

$FmtWikiLink = 'MyFmtWikiLink';
function MyFmtWikiLink($pat,$ref,$btext,$out=NULL,$pname=NULL) {
   $pg = FmtWikiLink($pat,$ref,$btext,'PageName',$pname);
   if (!PageExists($pg))
   {
       $t = preg_replace("/^.*\\./",'',$pg);
       if (PageExists("$t.$t"))
		  $ref = "$t/$t";
   }
   return FmtWikiLink($pat,$ref,$btext,$out,$pname);
}

Put this in your local.php, and "WikiWord" will automatically link to 
"WikiWord/WikiWord" if that page exists. Can easily be changed to go to 
"WikiWord/HomePage" too. Very handy if you have a lot of groups like I do.

Thanks for the help, John.

Jason



John Rankin wrote:
> Try something like the following in your local.php 
> 
> $FmtWikiLink = 'MyFmtWikiLink';
> 
> 
> function MyFmtWikiLink($pat,$ref,$btext,$out=NULL,$pname=NULL) {
>   $pg = FmtWikiLink($pat,$ref,$btext,'PageName',$pname);
>   if (PageExists($pg)) {
>       return FmtWikiLink($pat,$ref,$btext,$out,$pname);
>   } else {
>       $t = preg_replace("/^.*\\./",'',$pg);
>       if (PageExists("$t.$t")) {
>           return FmtWikiLink($pat,"$t.$t",$btext,'PageName',$pname);
>       }
>   }
>   return FmtWikiLink($pat,$ref,$btext,$out,$pname);
> }

> On Saturday, 1 November 2003 5:53 AM, J. Perkins <jason at 379.com> wrote:
> In addition to all of my public sites, I am using a private installation 
> of PmWiki as a "mind map" where I keep track of...well, just about 
> everything. In order to keep things organized, I started to split it up 
> into different groups for each topic. Each group has a main page with 
> the same name as the group, so it looks like "PmWiki.PmWiki". The with 
> this approach is that every time I mention the topic in a different 
> group, I have to give the fully qualified "PmWiki/PmWiki" to make the 
> link. I did this for a while and then got annoyed and modified 
> pmwiki.php to automatically look for $title.$title if plain old $title 
> didn't work. In the function "FmtWikiLink", I changed the last few lines to:
> 
>    if (PageExists("$group.$title")) $fmt=$WikiPageExistsFmt;
>    elseif (PageExists("$title.$title")) { $group=$title; 
> $fmt=$WikiPageExistsFmt; }
>    elseif (preg_match('/\\s/',$txt)) $fmt=$WikiPageCreateSpaceFmt;
>    else $fmt=$WikiPageCreateFmt;
> 
> I added the first "elseif" clause there. Now this works great, but it 
> requires me to edit pmwiki.php every release to make it work. Is there 
> any way to achieve this same result via an addon?






More information about the pmwiki-users mailing list