[pmwiki-users] automatic page titles (aless)

john.rankin at affinity.co.nz john.rankin at affinity.co.nz
Fri Aug 1 15:48:38 CDT 2008


> Date: Fri, 01 Aug 2008 16:31:54 +0700
> From: aless <alessors at gmail.com>
> Subject: Re: [pmwiki-users] automatic page titles
> [...]
>> Apostrophes (single quotes) need to be removed, because PmWiki uses
>> page names as file names and in the url. [...]
>> You could try and change the $MakePageNamePatterns array, which
>> function MakePageName uses. Define it in config.php.
>
> I found also the AlternateNamingScheme recipe in the Cookbook
> (http://www.pmwiki.org/wiki/Cookbook/AlternateNamingScheme), and
> following the instructions I came up with this array that should transform
>
> l'albero di natale => L_albero_di_natale:
>
> $MakePageNamePatterns = array(
>      "/'/" => '',                           # strip single-quotes
>      "/[^$PageNameChars]+/" => ' ',         # convert non-alnums to spaces
>      "/(^\\w)/e" => "strtoupper('$1')",     # initial caps
>
>      "/\\s+/" => '_'                        # Convert spaces to
> underscores
> );

It should be possible to handle the apostrophe too. One option
would be to use the ~ character in the pagename and url as a
surrogate for the ' and then convert "~" to "'" on output, in much
the same way as the above code converts '_' to ' '. This is done in
the custom $AsSpacedFunction.

You then have to add ~ to the allowed $PageNameChars, otherwise
PmWiki will remove it:

$PageNameChars = '-~[:alnum:]';

I'm not sure if ~ is treated as part of alnum, but I suspect not.

Hope this helps. I can provide more detailed instructions if you
need them.

JR






More information about the pmwiki-users mailing list