I know you can set the default template, but is there a way to turn off inheritance so a new child resource uses the default template rather than its parent template?
I'm not sure if there's a setting for that or not, but you could do it with a very simple plugin attached to OnDocFormSave:
if ($mode === modSystemEvent::MODE_NEW) {
$defaultTemplate = $modx->getOption('default_template');
if ($resource->get('template') !== $defaultTemplate) {
$resource->set('template', $defaultTemplate);
$resource->save();
}
}
This simpler version might work if attached to OnBeforeDocFormSave -- if so it would be more efficient:
if ($mode === modSystemEvent::MODE_NEW) {
$resource->set('template', $modx->getOption('default_template'));
}
Thanks BobRay.
That would definitely work had I not failed to leave out an important piece of information. I am writing a Knowledge Base site for our IT Department. When they create a new article, the template for that article has two template variables. We are a fairly busy office and it would only frustrate the techs if they have to save a document, then reopen it to gain access to the template variables.
I guess I could create a hidden parent resource with the correct template. Just seems unnecessary. Perhaps a checkbox for inheritable templates could be available in a forthcoming update of ModX??