[pmwiki-users] Hierarchical groups link notation...

The Editor editor at fast.st
Tue Jan 30 07:26:00 CST 2007


I have put together two notations for the hg system I'm tinkering
with, which look almost the same, but one provides absolute links, and
the other relative links. Both work exactly as intended.

However, I was wondering if anyone would care to try and combine these
two into one markup as they are both very similar.  I'm just not
exactly sure how to do it...

Markup('[[*','<var','/\\[\\[([\\*]+)(.*?)\\]\\]/e', 'hgabslinks("$1","$2")');
function hgabslinks($x,$y) {
	global $pagename;
	$subgroup = FmtPageName('$Group', $pagename);
	$subgroupsabs = explode("-", $subgroup);
	$xx = strlen($x);
	$i = 0;
	while ($i < $xx) {
		$link = $link . $subgroupsabs[$i] . "-";
		$i = $i + 1;
		}
	$link = substr ($link, 0, -1);
	return "[[$link$y]]";
	}

Markup('[[^','<var','/\\[\\[([\\^]+)(.*?)\\]\\]/e', 'hgrellinks("$1","$2")');
function hgrellinks($x,$y) {
	global $pagename;
	$subgroup = FmtPageName('$Group', $pagename);
	$subgroupsrel = explode("-", $subgroup);
	$xx = strlen($x);
	$i = 0;
	while ($i < $xx) {
		array_pop($subgroupsrel);
		$i = $i + 1;
		}
	$link = implode("-", $subgroupsrel);
	return "[[$link$y]]";
	}

Cheers,
Dan



More information about the pmwiki-users mailing list