We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21301
    • 93 Posts
    The 1.1 version works fine for me.
    It might be that you have spaces in your printpage templatename. You could use urlencode in the snippet to solve this:
    $printtemplate=urlencode("printpagetemplate");
    

      • 4266
      • 70 Posts
      Quote from: theo at Sep 03, 2005, 04:54 AM

      Can you tell me the URL of the printpagelink? And what URL do you see when the page reloaded?

      Theo! Here are the links:

      http://www.dors.biz/modx/index.html - page URL (see print link below the welcome head)
      http://www.dors.biz/modx/index.html?template=printpagetemplate - page URL after reload

      Here is html-content of the printpagetemplate:
      <body>
      <h1>[*#longtitle*]</h1><div>[*#content*]</div>
      </body>
      


      Urlencode had not help. I’m using plugin ChangeTemplate v. 1.1 too.

      I wonder how the printpagelink snippet tells to the ChangeTemplate plugin that page must be reloaded with new template? I don’t see any mention of this plugin in the snippet code:

      // Set the name of the template used for printing
      $printtemplate=urlencode("printpagetemplate");
      $id = $modx->documentIdentifier; // Get current document
      $link ="<a href=\"[~$id~]?template=$printtemplate\">print this page</a>";
      return $link;
        • 21301
        • 93 Posts
        Your snippet works fine.

        I wonder how the printpagelink snippet tells to the ChangeTemplate plugin that page must be reloaded with new template? I don’t see any mention of this plugin in the snippet code:
        Here’s how the snippet and the plugin work together:

        • The snippet creates a link with a parameter (?template=) on your page.
        • When you click the link the same pages is requested and the parameter is passed.
        • The plugin monitors all requests for this parameter.
        • When the parameter is found it will load the template specified.
        • And parse the request with this template instead.

        For the plugin to work you need to

        • Have a template named (in this case) ’printpagetemplate’.
        • Have to set the System Event ’OnLoadWebDocument’. (When you edit the plugin there’s a tab ’System Events’ where you can do this.)

        Sinc e the plugin doesn’t kick in I think there’s a problem with one of the two above.
          • 4266
          • 70 Posts
          Quote from: theo at Sep 05, 2005, 05:27 AM

          For the plugin to work you need to

          • Have a template named (in this case) ’printpagetemplate’.
          • Have to set the System Event ’OnLoadWebDocument’. (When you edit the plugin there’s a tab ’System Events’ where you can do this.)
          Sinc e the plugin doesn’t kick in I think there’s a problem with one of the two above.

          Sorry, but it doesn’t work huh The template name is correct and ’OnLoadWebDocument’ checked in plugin settings.
            • 21301
            • 93 Posts
            Mmm....

            You could create a plugin with the same Event and try this line to see if the plugin mechanism is working at all:

            $modx->documentContent = "DEBUG<br>";


            The result should be only ’DEBUG’ on your screen. If you still see your normal page there’s something wrong with your installation. If this works, it’s a bug in the ChangeTemplate plugin.

            Does the QuickEdit module work for you? If so, it’d mean there’s a bug in the plugin ChangeTemplate.

            Do you have phpmyadmin (www.phpmyadmin.net/) or can you access your mysql database?
            I wonder what your ’modx_site_templates’ table looks like.
              • 4266
              • 70 Posts
              Quote from: theo at Sep 05, 2005, 06:23 AM

              You could create a plugin with the same Event and try this line to see if the plugin mechanism is working at all:
              $modx->documentContent = "DEBUG<br>";

              The result should be only ’DEBUG’ on your screen.
              Yes, only DEBUG is displaying on screen.

              Does the QuickEdit module work for you? If so, it’d mean there’s a bug in the plugin ChangeTemplate.
              Yes, QuickEdit module works fine.

              I wonder what your ’modx_site_templates’ table looks like.
              Here is the screenshot (sorry for img quality):
                • 21301
                • 93 Posts
                Another Mmm...

                For some reason the plugin doesn’t work. What if you try the first version (selection by id) and try the link
                http://www.dors.biz/modx/index.html?template=2

                Try some debugging and see where things go wrong. Eg:
                $result ="DEBUG<br>";
                if (isset($_REQUEST['template'])) {
                  $overrideTemplate=$_REQUEST['template'];
                  $result .="[$overrideTemplate]";
                }
                $modx->documentContent = $result;
                
                  • 32963
                  • 1,732 Posts
                  Hmmm,

                  Is the Plugin Disabled?
                    xWisdom
                    www.xwisdomhtml.com
                    The fear of the Lord is the beginning of wisdom:
                    MODx Co-Founder - Create and do more with less.
                    • 4266
                    • 70 Posts
                    OK!  grin I’ve found that ChangeTemplate plugin works fine with all pages except index.html. Does anybody knows why? Browser loads regular full page both on "index.html" and on "index.html?template=2". I’ve tried to rename page alias to "main", but nothing changes.

                    When I try debugging (create plugin with your debugging code and checked OnLoadWebDocument event), just ’DEBUG’ is displaying on screen.
                      • 21301
                      • 93 Posts
                      Quote from: bugaev at Sep 06, 2005, 02:59 AM

                      When I try debugging (create plugin with your debugging code and checked OnLoadWebDocument event), just ’DEBUG’ is displaying on screen.
                      So your parameters get lost somewhere. I guess it’s something with the friendly URL’s? Or the rewrite rules in .htaccess. Anybody any ideas on this?