-
- 1,732 Posts
Quote from: theo at Aug 16, 2005, 09:44 AM
But for eg a low-bandwidth page it’d be usefull to change the template in the documentObject. Which can’t be done using the OnWebPageInit event since it’s called before the parser.
I’m trying to think of any other use for overriding settings in the documentObject. Can’t think of any other than the template
That’s true. We’ll be adding some new events in future versions that will allow you to do just that.
I’m still talking about separate "folders" for different language content. I’m just still looking for a way to carry over the language variable through an entire user session.
Right now, I’m using cookies and a TV. I would prefer a way to carry the $lang variable over in the query string; so I’m not dependent on the user having cookies enabled.
Using sessions gets tricky when you consider login/logout, or login errors, the issue of session timeout, and requires a special hack of the login snippet. I did that the first time I created a multilanguage site, but it took some hacking of the core parser script.
What I need is some way to add the &lang=$lang to the url after it’s been created by the parser (as in the case of [~...~] links), but before it’s shipped off to the server. I have been looking at ways to use regular expressions to find links to local pages in a parsed page (as in, not links to other sites, they don’t need the lang tagged onto them!), the question being how to add it without hacking core scripts, or needing specially crafted menu snippets, and without a severe performance hit.
I’m beginning to wonder if I just need to give it up, and make a multilanguage-enabled version, with the custom parser and custom login and menu snippets.
-
- 1,732 Posts
Hi Susan,
Have you created using the OnWebPagePrerender event. This will allow you to create a plugin to that you can use to add &lang to your urls.
That’s what I figured; the issue at hand is to work out a regular expression to locate all the "local" links to add the &lang to. I’ve hesitated, because this will have to parse the entire page looking for links, and I’m concerned about the performance hit. I suppose the only way to be sure is to try it and see.
-
- 93 Posts
What about using the ’Prefix for friendly URLs’ option and set this to a unique string for you site. That way you can easily recognize and filter local links. There’s probably an API call to find out about this prefix. A requirement for the plugin would than of course be that you have friendly URLs turned on.
I noticed that some old etomite snippets sill generate ’index.php’ links. Though most snippets use the makeURL function which makes it work just fine.
That would work on a site-by-site basis, but I’m trying to set this up so it will work out-of-the-box for any site. Searching for links that have the $base_url, or no http:// part would catch local links, even if they are relative.
Actually, the cookie method with a TV to pick up the cookie value works fine; it only requires one snippet to handle the initial setting of the $lang variable and the cookie, depending on which language the user selected. You call the snippet in the main page (which is also the folder) for each language, so the $lang variable is just the document Id of the main page selected. I’m just a little uneasy about browsers that have cookies disabled. But even so, they would get the full default language site, since the TV is set to use the default language if it can’t get the cookie value.
How does the variable get passed to the page, it it wasn’t in the query string of the URL for the page?