$printtemplate=urlencode("printpagetemplate");
Can you tell me the URL of the printpagelink? And what URL do you see when the page reloaded?
<body> <h1>[*#longtitle*]</h1><div>[*#content*]</div> </body>
// 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;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:
For the plugin to work you need to
Sinc e the plugin doesn’t kick in I think there’s a problem with one of the two above.
- 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.)
The template name is correct and ’OnLoadWebDocument’ checked in plugin settings.
$modx->documentContent = "DEBUG<br>";
Yes, only DEBUG is displaying on screen.
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, QuickEdit module works fine.
Does the QuickEdit module work for you? If so, it’d mean there’s a bug in the plugin ChangeTemplate.
Here is the screenshot (sorry for img quality):
I wonder what your ’modx_site_templates’ table looks like.
$result ="DEBUG<br>";
if (isset($_REQUEST['template'])) {
$overrideTemplate=$_REQUEST['template'];
$result .="[$overrideTemplate]";
}
$modx->documentContent = $result;
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.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?
When I try debugging (create plugin with your debugging code and checked OnLoadWebDocument event), just ’DEBUG’ is displaying on screen.