[pmwiki-users] Groupname by default

Hans design5 at softflow.co.uk
Mon Dec 3 08:57:47 CST 2007


Sunday, December 2, 2007, 11:03:21 PM, Stéphane Heckel wrote:

> I would like new pages created from a page that belongs to the "Geo" group
> to have "References" as groupname, ...
> ie, ...

> I edit the Geo.Switzerland page and I add [[UBS]]
> If I click on UBS, I would like the page Reference.UBS to be created using
> the References.Template.

1. To use a template for any page created in group 'References'
create a file local/References.php for your local group
customisations, and add to this file:

<?php if (!defined('PmWiki')) exit();
$EditTemplatesFmt = 'References.Template';


2. To have links pointing straight to pages in the References group:
What shall happen to normal links pointing to other pages in the same
group? [[xyz]] points to page Xyz in the current group by default.
do you want to stop this behaviour? If not would it be good enough to
use a slightly different markup to point to pages in the References
group?

a) to redefine what is called free links [[free links]]:

$RefGroup = 'References';
Markup('[[','links',"/(?>\\[\\[\\s*(.*?)\\]\\])($SuffixPattern)/e",
  "Keep(MakeLink(\$pagename,PSS('$RefGroup/$1'),NULL,'$2'),'L')");

If you add that to config.php it will apply to all free links in all
groups, probably breaking a few links, especially in the PmWiki group.
You could just add it to a local customisation file specific for the
group it should work for.

b) you could use  a slightly different link syntax for links pointing
to the References group pages. For instance the following is a
modification of the Category group link syntax, a ? replaces the !:
Add to config.php:

## [[?References]]
SDV($RefGroup,'References');
SDV($LinkRefFmt,"<a class='reflink' href='\$LinkUrl'>\$LinkText</a>");
Markup('[[?','<[[','/\\[\\[\\?(.*?)\\]\\]/e',
  "Keep(MakeLink(\$pagename,PSS('$RefGroup/$1'),NULL,'',\$GLOBALS['LinkRefFmt']),'L')");
# This is a temporary workaround for blank category pages.
if (preg_match("/^$RefGroup\\./", $pagename)) {
  SDV($DefaultPageTextFmt, '');
  SDV($PageNotFoundHeaderFmt, 'HTTP/1.1 200 Ok');
}

then [[?PageName]] will point to page References.PageName


  ~Hans




More information about the pmwiki-users mailing list