We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27293
    • 2 Posts
    Hello all!

    Bare with me here.

    The idea is to manipulate what template is used before the page loads. So basically, if you come in from a certain domain, it’ll set a cookie, and every time you load a page it’ll display the page using a different template.

    I’ve tried both the OnLoadWebDocument and OnWebPagePrerender, but achieved nothing, however, when i tried the OnWebPageInit, when i printed out the template ID that it was going to use, it was NULL, so i assume i’m on the right track, but this is where i hit a dead end. How do i now tell modx to use a template i tell it through the plugin, rather then the one it gets from the database?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      http://modxcms.com/forums/index.php/topic,1079.msg6748.html#msg6748

      As was mentioned in later posts in that discussion, it might be a better idea to use different stylesheets instead, like CSS Zen Garden does.
        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
        • 5340
        • 1,624 Posts
        May I suggest you use different css files for each template. Actually you will have only one MODX template but more designs controlled via CSS.

        at the top of the template where you load the css use a snippet
        [!loadCSS!]

        Inside loadCSS you read your cookies and decide which css file to use.

          • 27293
          • 2 Posts
          This is all well and good, and how’d i’d usually do it, however, the solution im after is to a problem regarding mobile templates.

          The idea is that if you are a mobile user, instead of seeing 10 etc different templates with only CSS changes, making button areas small and layout clunky, that you’d get a special mobile friendly template, with bigger designed areas for touch screen touches, information displayed where you need it, and reduced navigation, all of which requires a lot more then CSS changes.

          Good suggestions though, but sadly, completely seperate templates are needed.

          The solution posted by sottwell seems to be in the right direction, although maybe to buggy to use on a site receiving thousands of views, with a hight percentage of mobile users, but am trying it out and seeing if i can’t solve some of the problems brought up in that thread.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            There are a few discussions about mobile access; here’s one http://modxcms.com/forums/index.php/topic,34858.0.html
              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