On Tue, May 20, 2008 at 2:00 PM, Dominique Faure <[EMAIL PROTECTED]> wrote: > On Tue, May 20, 2008 at 8:08 AM, Henrik Bechmann > <[EMAIL PROTECTED]> wrote: >> All, >> >> Peter Bowers made some helpful observations and suggestions, which >> prompted me to make some changes resulting, I think, in safer, slightly >> faster, and more general code for this. The updated Beta 2 is at... >>>>> The code is at >>>>> http://www.pmwiki.org/pmwiki/uploads/Cookbook/grouptitles.php >> Any other comments are most welcome. >> >> Best, >> > > IMHO, one of the best feature of the original Pm's GroupTitle recipe > was to consider a search path when looking for titles, providing a > convenient way to 'override' the group title on specific pages: > > For example, if the [[GroupName.{$DefaultName}|!+]] link is a simple > way to come back to the group home page, it isn't very useful on the > GroupName.{$DefaultName} page itself. The search feature should allow > to (re)define it there (to an empty string in this case). > > The following code would be able to handle the path search, but I > haven't been able to find a "simple" way to allow fetching of empty > string definitions. > > function MakeGroupTitle($pn, $group = '') { > global $GroupTitlesPathFmt, $pagename; > if (!$group) { > $page = MakePageName($pagename, $pn); > if (preg_match('/^(.+)[.\\/]([^.\\/]+)$/', $page, $match)) > @list(/*$d*/, $group, $name) = $match; > if (!$group) return $pn; > } > SDV($GroupTitlesPathFmt, array( > '{{$FullName}$:GroupTitle}', > '{{$Group}.GroupAttributes$Title}', > '{{$SiteGroup}.GroupTitles$:{$Group}}', > )); > global $RedoMarkupLine, $MarkupTable; > foreach($GroupTitlesPathFmt as $v) { > $rdm = $RedoMarkupLine; > while(true) { > $RedoMarkupLine = 0; > $v = preg_replace($MarkupTable['{$var}']['pat'], > $MarkupTable['{$var}']['rep'], $v); > if(!$RedoMarkupLine) break; > } > $RedoMarkupLine = $rdm; > if($v) return $v; > } > return $group; > } > > > -- > Dominique >
BTW, replacing the last test: if($v) return $v; with: if($v) return preg_replace('/\\[(==|@@)\\]/', '', $v); you would be able to specify empty group titles using empty blocks ([==] or [@@]). -- Dominique _______________________________________________ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel