We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    I actually did something similar with the EPG photo gallery; I hacked the snippet to create javascript calls to switch stylesheets when clicking on the thumbnail instead of links to the larger image. It would be easy enough to have it make links for the template switcher instead.
      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
      • 32982
      • 674 Posts
      for read the id of the template whithout go to mysql simply mouseover template names and read the bottom bar and see the changes only change the id, in explorer could breack the direction but in firefox show all
        Jabiertxof (formerly XYZVISUAL)
        My bussines: http://marker.es
        https://www.youtube.com/user/jabiertxof/videos
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        The question with a snippet to generate the menu links would be, do you want ALL of your templates to be switchable?

        By manually creating the links (and really, how many templates are you likely to be switching to?) you can be selective; unless the snippet took an argument of a list of templates to include/exclude, and then you might just as well make the links yourself; it’s easy enough to copy/paste the links and just change the template’s id and the link’s text.

        Or use a TV, I suppose, and have a chunk with a list of templates to include or exclude...now that would be useful, you could also include a list of document ids to not allow switching, if you had a specific template for a certain document, and it was OK for everything else to use that template, but that form or whatever on the document really needed that template. As it is, I have it made so you have to put an HTML comment in the template you don’t want changed, which slows things down since the whole template has to be parsed first to see if that comment is there. And it won’t change any page using that template by default, while you may only have one page that you don’t want changed. This is making my head hurt... undecided
          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
          • 34162
          • 1 Posts
          The demo is no more online, it is a pity.
          Banzai use the same method for his website TattooCMS.it?

          Otherwise, something’s new?
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I was just getting sick of the IE crap with all the templates.

            You can see it again (single-page only, no cookie) at

            http://www.alandaniel.co.uk

            which is still very much "under construction".

            (click on the scrolling images)

            // TemplateSwitcher - plugin for MODx
            // uses OnLoadWebDocument event
            // stores template choice in cookie
            // comment out lines 10, 11 and 27
            // for single-page switch
            if(!strstr($modx->documentContent, "donotswitch")) { // this page is not switchable
                if (isset($_GET['template'])) {
                  $overrideTemplate = $_GET['template'];
            //    } else if (isset($_COOKIE['template'])) {
            //      $overrideTemplate = $_COOKIE['template']; 
                }
                if (isset($overrideTemplate)) {
                  $table = $modx->getFullTableName("site_templates");
                  $result = $modx->db->select("id, content",$table,"templatename = '".$overrideTemplate."'");
                  if($modx->db->getRecordCount($result) == 1) {
                    $row = $modx->db->getRow($result);
                    $modx->documentObject['template']=$row['id'];
                    $modx->documentContent = $row['content'];
                  } else {
                    $this->messageQuit("Error retrieving template.");
                  }
            //      setcookie("template",$overrideTemplate,time()+604800, "/", "", 0);
                }
            } // end if page is switchable
            
            
              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
              • 6726
              • 7,075 Posts
              I am a happy user of your switcher, great !

              Tip for those who have read the beginning of the thread and tried the example : use name of template instead of ID, e.g, if your template is named "original" :
              <a href="[~[*id*]~]&amp;template=original">Original template</a>

              Using the template id gave me a parse error : maybe because I am using friendly urls ?).

              Really nice to have this, Susan, many thanks grin
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 6726
                • 7,075 Posts
                No problem, I figured it out reading the thread, it was mentionned by Theo and I think it’s just great with template name smiley

                Quote from: sottwell at Jan 25, 2006, 04:26 AM

                Oops...my bad, I originally had it using ID, but that’s kind of awkward if you don’t know the ID of your templates, so I changed it to template name. Will correct the documentation and re-upload. <sigh>
                Thanks!
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l&#39;outil id
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Sorry...I originally had it using the template ID, but that’s kind of hard to determine, so I changed it to use the template name.
                    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
                    • 14779
                    • 256 Posts
                    I would like to incorporate this into each template, so no matter which template is shown, or which page you are on, you can switch to another template. How do I incorporate dynamic page id #’s?
                      PM me to find out how you can get a FREE ipad 2!
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      It’s automatic, it can be used for any page. The pages have to be uncached, though.
                        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