We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39273
    • 61 Posts
    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?
      • 3749
      • 24,544 Posts
      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'));
      }



        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 39273
        • 61 Posts
        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??