We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17237
    • 17 Posts
    I understand that this isn’t the standard procedure for a responsive site. My client was looking for a “quick fix” while the site was being rebuilt. The site was first developed in 2012 and over that time, things like tables, inline styles, including image and cell sizing (by pixels; not percent) and even 3rd party scripts(!) have been added through the rich text editor. I had created a responsive template and stylesheet a while back -- but that doesn't override inline styles. 

    So, my client asked me to look into a way to switch templates based on viewport. This way they can have a mobile version which will satisfy google; and still keep the  “full-site" content available — albeit via a desktop view. The plugin in question is switchtemplate. The documentation on that plugin didn’t include any info on where to put the call to initiate it. If you have any insight on that, or any other suggestions that might address this better, that would be greatly appreciated.  

    Thank you!!!
      • 3749
      • 24,544 Posts
      Plugins don't have a tag. Instead, they get "connected" to one or more System Events (on the System Events tab when editing the plugin). When the System Event fires, the plugin code executes. The switchtemplate plugin probably listens to a front-end System Event like OnLoadWebDocument.
        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
        • 17301
        • 932 Posts
        AFAIK the extra uses a key which you call in as a parameter in front end. So if the key was template1 I believe it's ?mode=template1 at the end of the url. It's a really great extra though and has many uses.
          ■ email: [email protected] | ■ website: https://alienbuild.uk

          The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • It could also be configured to switch the template on base of an url suffix. I.e. with .m.html to a mobile version.
            • 17237
            • 17 Posts
            thanks everyone for your replies. Im still not quite getting it...

            I see in the settings that the plug in is tied to system event like Bob Ray said; A screen shot is attached of the settings for the plugin
            Also, the pages/resources are cacheable.

            I'm still not understanding how to make it "switch"... which essentially is: at this viewport size, use this template
              • 17237
              • 17 Posts
              here are the plug in settings ...

              name: switchtest
              key: mobile
              extension: mobile.htm (looks like I have a typo here, but does this setting define the output resource? )
              chunk/template: mobilepage (name of mobile template)
              Template Type: template
              Cache output: yes
              output type: html

              do I have to define the key further somewhere else? or do something with context?

              thanks!
                • 17301
                • 932 Posts
                To give you an example if I have a page called untitled and my key settings are as follows:

                Key: mobile
                Ext: .mobile.

                I can switch the page template from its default one by replacing untitled.html with untitled.mobile. or untitled.html?mode=mobile
                  ■ email: [email protected] | ■ website: https://alienbuild.uk

                  The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                  • 17237
                  • 17 Posts
                  thanks, but still not working.

                  I've tried all of the above and still not working. and I don't necessarily want duplicate resources.. thought it could work similar to a media query

                  should I be editing the system events settings? anyone willing to help me out via private message?