We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 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  smiley

    That’s true. We’ll be adding some new events in future versions that will allow you to do just that.
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 21301
      • 93 Posts

      That’s true. We’ll be adding some new events in future versions that will allow you to do just that.
      Fantastic, it’s getting better and better! Can’t wait for the future versions! grin


      I wonder if the documentObject could be used in a multilanguage situation...hmm. Have to look into that.
      I think normally you’d want to translate pages yourself and have the OnWebPageInit event redirect to the correct page. Like Susan describes in other threads. The difference with the OnWebPageInit event would be that some code moves from the snippet to a plugin I guess.

      But with the new event you could translate the content on the fly! Have it translated by Bablefish or so! Unfortunately these translations are horrible. But I like the idea! It’d be powerfull to have an event to do 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.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 32963
          • 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.
            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.
          • 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.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 21301
              • 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.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 22097
                  • 37 Posts
                  Quote from: sottwell at Aug 17, 2005, 08:00 PM

                  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.

                  Why add it to every link? Isn’t it enough to use the WebPageInit to add it to the URL of the current page (if that is possible). Once you have figured out what language to use, every requested page should have that language I think.
                  • How does the variable get passed to the page, it it wasn’t in the query string of the URL for the page?
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 22097
                      • 37 Posts
                      Now that I think of it, it doesn’t really make sense. The method I had in mind then still requires cookies or sessionvars. But then you would not need to rewrite the url. Hmm, back to the drawingboard... undecided