[pmwiki-users] Hg tweaks...

The Editor editor at fast.st
Thu Feb 1 19:57:50 CST 2007


On 2/1/07, The Editor <editor at fast.st> wrote:
> Ok, I've come close to a solution to the problem of creating a pull
> down menu for subgroups (ZAP will use this with Hg to create pages in
> the proper locations...).  Much easier than I thought thanks to a tip
> from Kathryn...
>
> Given the following example where I'm trying to retrieve one instance
> each of One and Two...
>
> > > Main-One.A
> > > Main-One.B
> > > Main-Two.A
> > > Main-Two.B
>
> The pagelist can be set to (:pagelist group-Main-* fmt=#group:) and
> I'm almost there.  Give me
>
> Main-One
> Main-Two
>
> So I thought I would try to use the new BaseName feature in PmWiki...
>
> In config.php I put:
>
> $BaseNamePatterns['/^Main-/'] = '';
> also $BaseNamePatterns['/^Main\\-/'] = '';
>
> and in the pagelist template I changes {$=Group} to {=$BaseName}
>
> I get two bullet points but the text is gone.  Can someone point out
> what I'm missing.  I think I must be almost there...
>
> Cheers,
> Dan


Aha!

For those interested I finally came up with a solution to this--by
writing my own stripper markup.  Works great, and seemingly much
simpler than the basename patterns idea--though admittedly not as
smart.   (I'd be open to ideas for improving it...)

Basically, I added another zap var markup with this code:

Markup('zapstrip','<if','/\\{\\#h (.*?)\\}/e', 'zapstrip("$1")');
function zapstrip($x) {
	$xx = explode("|", $x);
	$x = substr($xx[1], strlen($xx[0]));
	return $x;
	}

Then I created this pagelist template:

[[#hggroup]]
(:if ! equal {=$Group} {<$Group}:)
(:input select subgroup '{#h {$$strip}|{=$Group}}':)
[[#hggroupend]]

What does this do?

Given wiki pages:

> > > Main-One.A
> > > Main-One.B
> > > Main-Two.A
> > > Main-Two.B

I can type (:pagelist group=Main-* strip=Main- fmt=#hggroup:) and
produce a pull down menu consisting of options One and Two--just what
I wanted.  Combined with ZAP and the subgroup vars, this can be used
to create pages at just the right place in a hierarchy automatically.
Really cool...

Suppose I could do a strip right also if needed...

Sivakatirswami, hope you are reading this.  I know you've been asking
for this repeatedly...

Cheers,
Dan



More information about the pmwiki-users mailing list