|
Cookbook /
LinkPageExistsFmtTooltipSummary: How to add tooltips to links
Status: Stable
Version: 2007-01-15
Prerequisites: pmwiki-2.1
Maintainer:
Categories: Links
Votes:
QuestionHow can I add a tooltip (small popup text that is displayed when you run with the mouse over a link) for a link to a existant page ? AnswerAdding the target page title as a tooltipAdding a tooltip using the title of the target wiki page is quite straightforward as demonstrated in LinkPageCreateFmtTooltip. Add to config.php: $LinkPageExistsFmt = "<a class='wikilink' title='{\$Title}' href='\$LinkUrl'>\$LinkText</a>";
Adding the target page description as a tooltipA description can be added to a page using the (:description ...:) markup. To display a page's description as a tooltip instead of the title, use $LinkPageExistsFmt = "<a class='wikilink' title='{\$Description}' href='\$LinkUrl'>\$LinkText</a>";
To display a page's description, but fall back to the page's title if a description isn't set, use the following:
$FmtPV['$DescriptionT'] =
'@$page["description"] ? $page["description"] : PageVar($pn, "\$Title")';
$LinkPageExistsFmt = "<a class='wikilink' title='{\$DescriptionT}' href='\$LinkUrl'>\$LinkText</a>";
Adding an arbitrary text as a tooltipUse links like Add to config.php
## [[target | text "tooltip"]]
Markup('[[|tt','<[[|',
"/(?>\\[\\[([^|\\]]*)\\|\\s*)(.*?)\\s*(\"(.*?)\")?\\s*\\]\\]($SuffixPattern)/e",
"Keep(ToolTipLink(\$pagename,PSS('$1'),PSS('$2'),PSS('$4'),'$5'),'L')");
function ToolTipLink($pagename, $tgt, $txt, $tooltip='', $suffix) {
global $FmtV;
$FmtV['$LinkAlt'] = $tooltip;
return MakeLink($pagename, $tgt, $txt, $suffix);
}
$LinkPageExistsFmt = "<a class='wikilink' href='\$LinkUrl' rel='nofollow'
title='\$LinkAlt'>\$LinkText</a>";
Notes
Contributors
CommentsUser notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |