[pmwiki-users] automatic page titles
Hans
design5 at softflow.co.uk
Fri Aug 1 03:07:43 CDT 2008
Thursday, July 31, 2008, 6:39:40 PM, Alessandro Orsi wrote:
> So, what's my question? Well, I would like (:title title with spaces
> and apostrophes and anything else I could fancy:) to be automatically
> added when I create a new page, better if from a page template, so I
> don't have to type the expression two times or copy paste.
>
> Now I have to:
>
> 1. create the link in a page:
>
> [[l'aquila]]
>
> 2. Click. Page "Laquila" is created, then add:
>
> (:title l'aquila:)
> I would like to skip point two. Is there any variable that stores
> "l'aquila" before it is converted to "Laquila" that I can use in a
> page template or somewhere else to automate the process?
No. Page names are generated by the function MakePageName.
> I know it can probably be done through a form, and I had a look at the
> recipe NewPageBoxPlus, but I'd like it to work also from free links (I
> don't use WikiWords).
Unfortunately using link markup you cannot insert the typed title into
the new pag's (:title :) markup automatically.
All you could do is specify a template page, which loads as the new
page. So you can have a blank (:title :) markup, but you still need
to fill it. See http://www.pmwiki.org/wiki/Cookbook/EditTemplates for
this.
A Fox form solution would insert it automatically.
You could try Fox. http://www.pmwiki.org/wiki/Cookbook/Fox
See http://www.pmwiki.org/wiki/Cookbook/FoxPageManagement
example 2
> I also had a look at the recipe AlternateNamingScheme to make page
> names a bit more readable, and I was wondering whether leaving
> apostrophes in page names would break something. In Moinmoin, for
> example, spaces are converted to underscores but apostrophes are left
> untouched:
> Moinmoin:
> l'albero di natale => l'albero_di_natale
> Pmwiki
> l'albero di natale => LalberoDiNatale
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.
For instance:
$MakePageNamePatterns = array(
"/[^$PageNameChars]+/" => ' ', # convert non pagename characters to space
'/((^|[^-\\w])\\w)/e' => "strtoupper('$1')", # convert first character after space to Upper
'/ /' => '_'); # convert spaces to underline
this will convert
l'albero di natale => L_Albero_Di_Natale
Or try this:
$MakePageNamePatterns = array(
"/'/" => ' ', # convert single-quotes to space
"/[^$PageNameChars]+/" => ' ', # convert everything else to space
'/((^|[^-\\w])\\w)/e' => "strtoupper('$1')",
'/ /' => '');
this will convert
l'albero di natale => LAlberoDiNatale
instead of stripping the single quote it gets converted into a space
first, which has the effect that the following word will start with
an Upper character.
But this will also convert for instance
a day's work => ADaySWork
To avoid capitalisation of a single letter following a single quote
and which in turn is followed by a space, one could use:
$MakePageNamePatterns = array(
"/'(\\w )/" => '$1', #strip single quote followed by single letter
"/'/" => ' ', # convert single-quotes to space
"/[^$PageNameChars]+/" => ' ', # convert everything else to space
'/((^|[^-\\w])\\w)/e' => "strtoupper('$1')",
'/ /' => '');
then you get
l'albero di natale => LAlberoDiNatale
a day's work => ADaysWork
~Hans
More information about the pmwiki-users
mailing list