We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36516
    • 179 Posts
    I'm running around in circles trying to solve a very old problem that I swear I solved months, even years ago, and can no longer achieve despite much searching and reading. And it's a silly little problem everyone must have. Apologies if I'm repeating but I just can't work it out.

    Why wouldn't someone want to arrange to have children of a given resource use *or* inherit a predefined template?

    First off, can anyone confirm that the current standard behaviour in Revo 2.3 is that child resources inherit their template from their parent? It does seem that's whats doing on, in spite of a system setting that indicates a side-wide default template. I presume that setting applies only to the root.

    I remember the day I discovered how to use something like Form Customisation to cause children to use a template of my choice, depending on the parent. I vaguely remember someone explaining how to accomplish that and the going off and doing it successfully - it made me very happy, but after all this time, and fresh research, I can't figure it out again or even find evidence of having done it myself! Incredibly frustrating.

    What I've discovered instead is that if I create a resource/create set with a default value for "template" ('5', for example), it then causes the site-wide default template to that template. Doesn't matter where I create a new resource, everything new uses template #5. Now that can't be right in any case, and I can't help wondering if that's a bug and if it were fixed then my problem would be solved. It seems the setting simply isn't limited to the template constraint indicated by the set I've created.

    The last dicussion I could find on the subject (https://forums.modx.com/forums/thread/32445/new-revolution-feature-form-customization?page=5#dis-post-177321) was about 4 years old and other people were discussing plugin scripts that could achieve this. I think Ryan Thrash even said he planned to incorporate it into a subsequent build, or something like that, so I wonder if it's not standard behaviour that children always inherit their parent's templates, which does seem to be the case.

    There are a couple of related plugins (http://modx.com/extras/browse/?search=inherit+template). I doubt either of them are going to let me dictate the template I want, instead simply causing inheritance which it seems to me is already supported in the core.

    This question has been answered by sottwell. See the first response.

    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      As far as I know, children do inherit their parent's template.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 36516
        • 179 Posts
        Thanks Susan. Do you know about controlling inheritance using FC? I'm so sure I've done it before, and now it really test seem broken. If it wasn't I think that would be the solution.
          • 36516
          • 179 Posts
          Steps to test this potential bug in 2.3:

          1 - Create a new "resource/create" set in Manager Customization ("Form Customization" - the menu item isn't the same as the page title, something else that ought to be tweaked).
          2 - Edit, and set the "Template" (at the top) to one you can use as a parent resource.
          3 - Set the default value for "template" field (near the bottom, under "modx-resource-main-right") to the ID of a template that is not the side default indicated in System Settings.
          4 - Create a new document resource as a child of any parent resource and see that the template for that resource has been set to the one indicated by this rule set, even if the parent template isn't that indicated by the "Template" setting to which the rule set applies.
            • 3749
            • 24,544 Posts
            If I'm understanding you, that would be the normal behavior for Form Customization. In step 3, you've told it to use that Template for every resource and it does. I don't think there's a way to inherit the parent's template with FC.

            There is also this: http://modx.com/extras/package/inherittemplate, though I don't know if it works in 2.3.

            As Susan says, I think inheriting the parent's template is the default behavior if you create the resource by right-clicking on the parent in the tree and select "Create -> Create a Document Here."
              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
              • 36516
              • 179 Posts
              I'm almost certain I've done it before. I'm so sure I remember the elation I experienced when I confirmed that it could be done without an addon.

              If I make a set that applies only to the create/edit of a certain template, and it is *another* setting in the set that is also called "template" (no cap 'T'), near the bottom, what use would giving that a default value be?

              I can see what you're saying, the option doesn't seem to make much sense either way. All the more reason to wonder what it was intended for. Setting a default value for 'template' won't ever achieve anything more than what the system setting already does. It seems that setting is really only there for the sake of changing the label in the create/edit form.

              If it *did* take that value and do something useful with it, say, applying it to children created under that parent, that would actually be additional functionality, though really there ought to be a 'child template' setting in the 'page settings' tab.

              I shall do more research to work out where I managed to solve this problem, and report back if I work it out.
                • 3749
                • 24,544 Posts
                AFAIK, FC doesn't have access to the parent object, which would be necessary to use its template. I could be wrong.
                  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