[pmwiki-users] Help with tooltips recipe (LinkPageExistsFmtTooltip)

f.r.salomons salomons at wanadoo.nl
Sun Jan 14 05:46:57 CST 2007


I find the recipe LinkPageExistsFmtTooltip very interesting. However, 
there seems to be something wrong with it.

1. The first part works fine: when I add

$LinkPageExistsFmt = "<a class='wikilink' title='\$Title' 
href='\$LinkUrl'>\$LinkText</a>";

to my config.php, at every link a tooltip shows up nicely with the title 
of the page.

2. In the second part, something goes wrong. When I add the code as 
stated below, tooltips show up with the wrong content. They should 
contain what's indside $description, and if there's no description it 
should contain the title of the page that the link points to. In 
reality, the tooltips contain "[description]T" (if there's a 
description) and otherwise only "T". I guess there is some simple 
mistake in the code, but I cannot correct it. Could anybody help me?

Thanks,
Frits

The second part of the code reads as follows:

$FmtP['/\$Description/e'] =  'DescriptionFunction($pagename,0)';
$FmtP['/\$DescriptionT/e'] =  'DescriptionFunction($pagename,1)';

function DescriptionFunction($pagename,$use_title=0) {
   global $PCache;

   if (!isset($PCache[$pagename])) {
     $page=ReadPage($pagename, READPAGE_CURRENT);
      @PCache($pagename,$page);
   }
   $description=@$PCache[$pagename]['description'];

   if ( $use_title && ! $description ) {
 
$description=((@$PCache[$pagename]['title'])?$PCache[$pagename]['title']:FmtPageName('$Title',$pagename));
   }
   $description=preg_replace("/[\"']/","",$description);
   return $description;
}

$LinkPageExistsFmt = "<a class='wikilink' title='\$DescriptionT' 
href='\$LinkUrl'>\$LinkText</a>";





More information about the pmwiki-users mailing list