|
Cookbook /
HrefPageDirectiveSummary: How to get the href address to a particular wiki link
Version:
Prerequisites: requires at least PmWiki version: 2.0.10 (should work on earlier versions); last tested on PmWiki version: 2.0.10 and version 2.1.26
Status:
Maintainer: MarkS
Categories: Links
QuestionHow can I get the href address to a particular wiki link? AnswerAllow a (:href Main.StaffInfo :) Page Directive. Example code to get this working;
if (defined('PmWiki')){
## (:href Main.StaffInfo :)
Markup("href","<{$fmt}",
"/\\(:href\\s(.*?)\\s*:\\)/e",
"Keep(getHrefFromWikiLink(\$pagename,PSS('$1')),'L')");
}
function getHrefFromWikiLink($pagename, $tgt=NULL, $txt=NULL){
#echo "getHrefFromWikiLink";
$link = MakeLink($pagename,$tgt,$txt);
$hrefToken = "'";
$hrefStart = strpos($link, "'", strpos($link, "href"));
$hrefStop = strpos($link, "'", $hrefStart + 1);
$hrefText = substr($link, $hrefStart + 1, $hrefStop - $hrefStart - 1);
#echo $hrefText;
return $hrefText;
}
Notes
ReleasesCommentsContributors |