[pmwiki-users] shortening Links with $LinkFunctions

adam overton a at plus1plus1plus.org
Sat Apr 2 10:20:27 CDT 2011

i'm wondering if i'm going about something the wrong way.
i'm trying to get a link like [[Group/]] to output http://mysite.com/Group, as opposed to http://mysite.com/Group/DefaultName

here's some background:

the $DefaultPage for my site is "index";
via some fancy clean urls and .htaccess footwork, my site now successfully displays the correct default page (Group/index) with either:

this much works.

but now i'd like for any links like [[Group/]] to resolve to 
instead of

so, i tried creating the following $LinkFunctions, but it turns out it seems to only works for links beginning with http://...
for instance, the following function successfully shortens http://mysite.com/Group/index

$DefaultName = "index";
$LinkFunctions['http:'] = 'ShortenLinkUrl';
function ShortenLinkUrl($pagename,$imap,$path,$title,$txt,$fmt=NULL) {
	global $DefaultName;

	$path = (preg_match("#^(.*)/".$DefaultName."$#", $path, $m)) ? $m[1] : $path;
	return LinkIMap($pagename,$imap,$path,$title,$txt,$fmt);

how do i go about doing the same thing for [[Group/]] markup?
thanks a bunch for the advice,

More information about the pmwiki-users mailing list