[pmwiki-users] Group name based $XLLangs (multilanguage Wiki)?

Oliver Betz list_ob at gmx.net
Sun May 22 13:34:08 CDT 2011


Peter Bowers wrote:

[...]

>>>My understanding of pretty URLs is that they simply change
>>>www.example.com/pmwiki/Group/Page to
>>>www.example.com/pmwiki/pmwiki.php?n=Group/Page behind the scenes.
>>>Thus the $_REQUEST['n'] (or $_GET['n']) is still available regardless
>>
>> I don't think so if someone is using "$EnablePathInfo = 1;"
>>
>> Look at mwiki.php, lines 302ff. There is also another request method,
>> with the "pagename" parameter instead of "n".
>
>Yes, I saw that, but I *believe* it is something left over from
>something obsolete in pmwiki.  As I look at the Cookbook/CleanUrls
>page It appears that all the .htaccess examples I see there end up

I never use rewrite rules but the (IMO much simpler) PmWiki setting
 "$EnablePathInfo = 1;"

In addition, I use a wrapper script like
 <?php chdir('pmwiki'); include_once('pmwiki.php');

The name of this wrapper script has no .php extension, I set the
handler in the .htaccess file. This way I get nice URLs:

 myhost.tld/wrapper/Group/Name

[...]

>> Can I call MakePageName() early in config.php?
>
>No, this is the function that often causes caching issues.  It calls
>FmtPagename() which calls PageVar() which caches various info about
>the page, perhaps prematurely.

I didn't follow the code enough to see under wich circumstances
FmtPagename() is called.

>>>Unfortunately $pagename can still be blank if the user is just looking
>>
>> Correct, I missed this. But this is more a skin problem - the "Logo"
>> link has to be a full URL to the current default page instead of
>> $ScriptUrl, else the language information is lost anyway.
>>
>> A link to $ScriptUrl will always start the default language.
>
>Sorry, you've lost me here.  $ScriptUrl always points at pmwiki.php,
>right?  I'm not sure I'm seeing the connection to a pagename or a

No. In my example above, it's "http://myhost.tld/wrapper"

>language or anything else...?
>
>And the "Logo" link is normally set using PVs which are handled long
>after farmconfig.php and config.php unless I'm misunderstanding
>something...  (Isn't this set during the call to MarkupToHTML()?)

PmWiki does a good job assembling the correct value for $ScriptUrl
(used my most skins for the "Logo" link). No need to set it manually
in config.php.

>Maybe I've misunderstood the basic question.  Are you trying to get
>access to the name of the page early on in config.php?

No. I just want to get the group name to make language settings
depending on patterns in it:

foo_en, bar_en should get English settings while foo_de, bar_de should
be German.

$DefaultPage is also switched depending on the language, and the
"logo" link in the skin is changed to point to the the full URL of the
default page, so the user stays in the selected language.

[...]

>add to config.php towards the top:
>===(snip)===
>if (!$pagename) $pagename = $DefaultPage;
>$pagename = preg_replace('/\.html$/', '', $pagename);
>list($group, $name) = preg_match('/^(.*?)[.\/](.*)$/', $pagename);
>===(snip)===

You are right, I should not make it more complicated than it is. Since
the scenario is well controlled (internal links), I don't even need to
handle the .html extension.

If the user provides a wrong URL, he gets the default language start
page.

Oliver
-- 
Oliver Betz, Muenchen (oliverbetz.de)




More information about the pmwiki-users mailing list