I was looking for a way to apply a different template to a document at runtime. This way I could create a ’print this page’ template without menu’s etc.
Does anybody know how to do this easily?
I couldn’t find a way so I modified the core code a bit. See below. It’s just a nasty hack but it works for me. Are there any plans to support this via an API call or event? I tried creating a plugin at first, but there’s no suitable event to attach the plugin to.
Maybe adding an event where I now have my little hack?
EDIT: I noticed that moving the hack to just before the ’return $documentObject;’ statement preserves your template variables. Because the next query uses the template variable this makes sense.
From: document.parser.class.inc.php
# this is now the document :) #
$documentObject = $this->fetchRow($result);
// Start template override hack
$overrideTemplate=$_REQUEST['template'];
if ($overrideTemplate!="") {
$documentObject['template']=$overrideTemplate;
}
// End template override hack
// load TVs and merge with document - Orig by Apodigm - Docvars