We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14779
    • 256 Posts
    Quote from: davidm at Jan 25, 2006, 04:22 AM

    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

    Now by name of template, do you mean the name that is listed in the ModX manager? Like Degault Template, or Back in Black Template. What about spaces and capitals in the template name? And should ’id’ be the ID of the document to display with the selected template?
      PM me to find out how you can get a FREE ipad 2!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Yes and yes.
        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
        Ok, When I click any link, I get the Site error page.(but the error page has the selected template)

        this is what my chunk looks like:

        <div class="switcher">
        <ul>
        <li><a href="[~[*23*]~]&template=Back in Black Template">Default</a></li>
        <li><a href="[~[*23*]~]&template=Green">Green/Gray</a></li>
        <li><a href="[~[*23*]~]&template=light">Light</a></li>
        <li><a href="[~[*23*]~]&template=OrangeIT">OrangeIT</a></li>
        <li><a href="[~[*23*]~]&template=PlexiGlass">PlexiGlass</a></li>
        <li><a href="[~[*23*]~]&template=Soft">Soft</a></li>
        <li><a href="[~[*23*]~]&template=Space">Space</a></li>
        <li><a href="[~[*23*]~]&template=Tabs">Tabs</a></li>
        </ul>
        </div>


        The document that this chunk is on is ID#23. This is the only document that I want to change, I am using the snippet code that Susan commented the cookie stuff out of.
          PM me to find out how you can get a FREE ipad 2!
          • 10487 MODX Staff
          • 1,535 Posts
          Garry Nutting Reply #24, 20 years ago
          Don’t directly enter your document ID, leave it as [~[*id*]~].

          The document ID will be automatically entered for you so you’ll get a link like [~23~] which will work just fine.
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 14779
            • 256 Posts
            Marvelous! Thank you!
              PM me to find out how you can get a FREE ipad 2!
              • 12511
              • 4 Posts
              Hi all,

              I made plugin, base on template switcher plugin, the code like this:
              // 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
                    $id = $modx->getDocumentIdentifier('id');
                    $table = $modx->getFullTableName("client_site");
                    $result = $modx->db->select("id, template",$table,"DocumentId = ".$id);
                    if($modx->db->getRecordCount($result) == 1) {
                        $row = $modx->db->getRow($result);
                        $file = $row['template'];
                        //Start the buffer
                        ob_start();
              
                        //include
                        include $file;
              
                       //get contents from the buffer
                       $ob_contents = ob_get_contents();
              
                       //and kill/delete the buffer
                       ob_end_clean();
              
                       $modx->documentContent = $ob_contents;
                    }
              } // end if page is switchable
              


              My Table : modx_client_site
              id | DocumentId | Template
              1  | 2          | assets/templates/AllTemplates/bamboo/index.html
              


              when i change value in column template with another template and i refresh browser, the page still display the old template before i change, but if i clear cache in the manager and i refresh browser, the browser display new template, that I need but without clear cache

              is there any way to do that, change template without clear cache in the manager

              regards,

              yono
                • 22303 MODX Staff
                • 10,725 Posts
                Yes, don’t cache the page.
                  • 12511
                  • 4 Posts
                  Yes, don’t cache the page.

                  ah...so simple, thank’s

                  regards,

                  yono
                    • 12511
                    • 4 Posts
                    I have install 9.6, but i have error like this :
                    ERROR: Too many forward attempts!

                    The request could not be completed due to too many unsuccessful forward attempts.
                    what wrong with my plugin..?

                    Thank’s

                    Yono
                      • 25663 MODX Staff
                      • 12,272 Posts
                      The template swicher plugin tends to cause more problems than it solves. I suggest looking for alternate solutions to your problem.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me