AlternateNamingScheme-Talk
This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.
Discussion
You might want to consider this carefully before implementing. There is no benefit if you join wiki words by default. There is probably significant benefit if you expect to disable wiki words and just use [[ ... ]] markup.
This recipe doesn't play properly with trails. The trails script uses the $AsSpacedFunction
to space wiki words before building the list of trail stops. As discussed above, the AlternateNamingScheme uses 2 spacing functions: one to turn underscores in page names into spaces and one to space wiki words. PmWiki uses the same function for both tasks. PITS.00103 describes a proposed work-around.
This "recipe" doesn't seem to go along well with MarkupExtensions, probably because that plugin also redefines AsSpacedFunction? -- Arjen
- WikiWords get spaced using the
$SpaceWikiWords
function, which extendmarkup.php sets to 'SpaceWikiWords' -- this is an enhanced version of PmWiki's AsSpaced function. If$SpaceWikiWords
= 1, the text of links to WikiWords is spaced, eg Wiki Words. So if you disable this function, you will probably get an 'error undefined function' if$SpaceWikiWords
= 1. - Page Titles (the name above the page text) get spaced using the function ULAsSpaced -- it just turns underscores into spaces. PmWiki uses
$AsSpacedFunction
to space titles, so spacewikiwords.php includes a line to set$AsSpacedFunction
= 'ULAsSpaced'. Notice that if we apply ULAsSpaced to a WikiWord, it will have no effect. That's why we need a separate $SpaceWikiWordsFunction. - The reference to markup.php was a typing error.
Suppose I write [[Apple iTunes]]
and [[Novell NetWare]]
. The alternate naming scheme will create pages called Apple_iTunes and Novell_NetWare
. The $AsSpacedFunction
(ULAsSpaced) will cause the titles to display as Apple iTunes and Novell NetWare.
Suppose I now write a reference to SomePage. The $SpaceWikiWordsFunction will cause this to display as Some Page, if $SpaceWikiWords
= 1. However, this will be treated as a reference to Some_Page, as if I had written [[Some Page]]
. On the other hand, if $SpaceWikiWords
= 0 (or $SpaceWikiWordsFunction = 'ULAsSpaced'), the link will display as SomePage, but still link to Some_Page.
The following settings achieve this:$SpaceWikiWords
= 1;$AsSpacedFunction
= 'ULAsSpaced';
$SpaceWikiWordsFunction = 'SpaceWikiWords';
http://forums.seochat.com/showthread.php?p=50891&highlight=underscores+hyphens#post50891 - Google recognize hyphens as words' separators, not underscores. I am use space 2 hyphen replacing, but can be conflicts with real hyphens in pagenames.
The treatment of capitilization is inconsistent compared with WikiWords. For example:
- Search and Rescue? becomes Search_and_Rescue
- search and rescue? becomes Search_and_rescue
- Search And Rescue? becomes Search_And_Rescue
etc.
Capitalization is only enforced on the first word. This causes a confusion of pages on Unix (Linux) systems where filenames are case-sensitive and different capitilization is applied in the link text.
If you want consistent capitalization go to the function MakeULPageName() in spacewikiwords.php and replace the line:
$name=ucfirst(str_replace(' ','_',trim(preg_replace("/[^$PageNameChars]+/",' ',$m[2]))));
with
$m[2] = ucwords($m[2]);
$name=str_replace(' ','_',trim(preg_replace("/[^$PageNameChars]+/",' ',$m[2])));
This will for capital letters for the first letters of each word.
This works with trails okay. As the poster above said, it is probably better to use '-' hyphens rather than underscores '_' as not all search engines see underscores as spaces.
Hope this helps.
davidof - 07 September 2005
Error: I get the following error:
Fatal error: Call to undefined function wikilink() in *****/spacewikiwords.php on line 120
QUESTION: how is the modification to $MakePageNamePatterns
supposed to be set?
If I insert the following in config.php
$MakePageNamePatterns = array( "/'/" => '', # strip single-quotes "/[^$PageNameChars]+/" => ' ', # convert everything else to space "/((^|[^-\\w])\\w)/e" => "strtoupper('$1')", "/ /" => '_'); # Convert spaces to underscores
I get this error:
Many thanks HYPERGURU
- I was having the same problem (only in linux, not in Windows). I solved removing the variable reference in the second rule, changing it to: (MarcioRPS February 07, 2006, at 01:47 AM)
"/[^-[:alnum:]]+/" => ' ', # convert everything else to space
QUESTION: Is there a way to make this work for groups as well?
I'm not very sure it does not allready work for groups, did you test??? Could you say exactly what's not working???
- I'm quite confused by the amount of comments and information given above. Anyway, not dwelling too much into complicated side notes and suggestions, yet basing on the two recipes above + some other one found on some other page here (not in the Cookbook), I've created a solution which works perfectly (as for now) for me.
- Tested only with
[[free links]]
(I have
- disabled - as by default since PmWiki 2.1 beta2)$LinkWikiWords
=0; - Works for default ISO-8859-1 encoding, as well as for UTF-8 (see at the top of your PmWikiXx.XLPage)
- Works with PmWiki.WikiTrails
- Not tested with the Markdown recipe (probably won't work together in current shape, as this one changes the
$AsSpacedFunction
)
cookbook
directory, then in local/config.php
add line of: include_once("$FarmD/cookbook/spacedTitles.php");
)
What about the original question:
So... how do I get underscore_separated_names, all lower case, no capital letters?
Insert this code in config.php
$MakePageNamePatterns = array( "/'/" => '', # strip single-quotes "/[^[:alnum:]_-\\s]+/" => '', # convert non-alnums to spaces "/([\\w]+)/e" => "strtolower('$1')", # make all lowercase "/\\s+/" => '_' # convert spaces to underscores ); $GroupPattern = '[\\w]*(?:-\\w+)*'; $NamePattern = '[\\w]*(?:-\\w+)*';
The downside of this is that all the pages in PmWiki and Site will no longer be found. I'm not sure how to get around this.Kathryn Andersen February 12, 2007, at 10:43 PM
I just did troll this recipe, I admit, but it was very messy and hard to understand. I over-valued a lone sugestion that was almost forgotten on the end of the page, but that was Pm's suggestion for the way to do that, so I divided the whole recipe in two, stating that there are two ways of acomplishing it, and I put the vast amount of comments in a block, to make things clearer...
Talk page for the AlternateNamingScheme recipe (users?).