[pmwiki-users] Markup to extract a substring for a Group Name

Petko Yotov 5ko at free.fr
Thu Oct 25 17:44:15 CDT 2007


On Friday 26 October 2007, Randy wrote:
> I'm using PmWiki 2.1. I keep my content and talk pages separated by
> group, using the same page name. The group name simply has the suffix
> "Talk". For example MyGroup.MyPage and MyGroupTalk.MyPage.
>
> I want to put a link on the Sidebar, so that when I'm on any Talk
> page the user can go to its content page. (The other direction is
> easy: {$Group)Talk.{$Name}.) How do I extract the current group name
> minus the "Talk" suffix, so I can do {$GroupBaseName).{$Name}?


Placing the -Talk- in the middle of the group.pagename is tricky. If you wish 
to place it at the end of the pagename, it is easier.


If you use a recent beta, try adding this in config.php. Here is what I use, 
either one:

  $BaseNamePatterns['/-(Discussion|Draft|Talk|Archive)$/'] = '';
  $BaseNamePatterns['/^(Discussion|Talk)-/'] = '';

The first one is recommended, as the talk page may be better to be in the same 
wiki group.

This means, that the page variable {*$BaseName} will be stripped of:

   any appended "dash" then Discussion, Draft, Talk or Archive;
   any prepended Discussion or Talk then "dash".

A pagename MyGroup.MyPage can have a talk page MyGroup.MyPage-Talk.

And then, I use [[{*$BaseName}]] which will always be the Group.Page stripped 
of any Talk, Discussion, Archive etc. (it exists), and [[{*$BaseName}-Talk]] 
to point to the talk page.

I can add them even to the Site.PageActions page.

Hope that helps,
Petko




More information about the pmwiki-users mailing list