Quote from: sderuiter at Feb 21, 2007, 03:22 AM
No. A new document gets loaded with the correct (not blank) template pre-specified. Thanks.
You are right,.. I’ve now noticed the same thing. The fun thing is to change the template as soon as you’ve started a new document. You’ll notice that when the page refreshes suddenly the fields are hidden as expected. It turns out that the $content[’template’] isn’t initialized to any value when you start a new document (when changing the template $content[’template’] get’s it’s value from a POST variable).
Luckily a small change to the code can bring relieve. Besides the $content var there’s also a $default_template which happens to hold the id of the default template. Just what we need. So changing the first few lines of code of the plugin to this should improve things a little:
<?php
// Set variables
global $content,$default_template;
$template = isset($content['template']) ? $content['template'] : $default_template;
?>
edit: Come to think of this, why is there a test for a template value at all? Other then making sure that the plugin only activates when you’re adding or editing a document instead of any of the other manager functions I can see no reason.. If that is the case it would be just as simple to look for the correct action:
<?php
if (($e->name == 'OnDocFormRender' && ($_REQUEST['a']==27 || $_REQUEST['a']==4) ){
//----//
}
?>