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

    I use Mobile Template Switcher plugin.. for redirect template from web template to mobile template..

    but I have problem with my pages which cached.. embarrassed

    Anybody know how to make "Mobile Template Switcher" Plugin.. For page cached ? huh




    Regards,

    Syu11 laugh
      • 3749
      • 24,544 Posts
      I think your only choices are to leave the pages uncached, or clear the cache in code:

      http://modxcms.com/forums/index.php/topic,33244.msg202446.html#msg202446

      Both will slow things down. I think leaving the pages uncached would be faster than clearing the whole site cache for each page load.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 22683
        • 41 Posts
        Quote from: BobRay at Aug 06, 2009, 01:41 AM

        I think your only choices are to leave the pages uncached, or clear the cache in code:

        http://modxcms.com/forums/index.php/topic,33244.msg202446.html#msg202446

        Both will slow things down. I think leaving the pages uncached would be faster than clearing the whole site cache for each page load.

        shocked Thanks BobRay...

        I will try clear the cache in code.. But if uncached would be faster than clearing the whole site cache for each page load.. I will use uncached smiley

        I want to ask again.. what plugin can used in mode uncached.. Like snippet [!name_snippet!] ?? grin



        Regards,

        Syu11
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          You can’t. If the page is cached, the whole finished page is taken from cache; how can the template be switched? The page is already generated with the original template.

          You could create two documents, using two different templates, with the mobile one just using a TV or a snippet to get the content from the main document so you don’t need to duplicate the content, and each with a TV to indicate the ID of its corresponding document. Then use a snippet to detect the browser type and get the TV value, and redirect to the other type of document if necessary. Keep them in separate container/documents, and have their menus only display the items in their respective branches of the Document Tree.

          This way you would have both documents in the cache.

          Can’t you do the same thing with CSS? Similar to a print .css file? Most handheld browsers should recognize the handheld media type. If they don’t, you could again use a snippet to determine the browser type and output a different css file name:
          <link rel="stylesheet" type="text/css" href="assets/templates/mytemplate/[!BrowserType!].css" media="all" />
          By calling the snippet uncached, it will get processed even if the page is cached.
          http://www.howtocreate.co.uk/tutorials/css/mediatypes
            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
            • 3749
            • 24,544 Posts
            Sottwell’s is (as usual) a much better solution. A snippet can identify the user agent and use this to put the proper css in place:

            $modx->regClientCSS(file_get_contents('path_to_css_file'));
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 22683
              • 41 Posts
              smiley Sottwell & Bobray, Thanks very much for solution..







              Regards,

              Syu11