We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26401
    • 247 Posts
    I’d like all new resources under News to use a template called news, without the parent template actually using this template, I know there’s a way of doing this in EVO using some plugin and a TV. I remember reading that this would be possible in revo but couldn’t find anything on this.

    Is there a way to do this?
      • 3749
      • 24,544 Posts
      I think you’d have to write a custom plugin to do that. It wouldn’t need to use a TV. You’d probably tie it to OnBeforeDocFormSave and just check the parent ID and change the template if it was the News document’s ID.

      If you need to change the template before the user sees the form, you could tie it to OnDocFormPrerender. I’m not positive that would work, but I’m pretty sure it would if you checked $_REQUEST[’parent’] and set _REQUEST[’template’]

      There was a plugin in Evolution that used the parent template as the default template, but that’s not what you want and I don’t think it exists in Revo yet (could be wrong). If it does, you could probably modify the code to do what you want.
        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
      • The inherit template plugin for Evo now has a configuration setting to either use the parent’s template or the first sibling’s template. That way you would only need to create one child resource with a template setting; the rest will be automatic.
          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
          • 3749
          • 24,544 Posts
          Quote from: sottwell at Sep 07, 2010, 05:15 AM

          The inherit template plugin for Evo now has a configuration setting to either use the parent’s template or the first sibling’s template. That way you would only need to create one child resource with a template setting; the rest will be automatic.

          Nice. I just checked and I don’t see it for Revo.

          Is there a Manager UI for it? If not, it shouldn’t be too hard to convert.
            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
          • huh It’s just a plugin with the configuration option in its Configuration tab. I presume Revo also has configuration for its plugins?
              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
              • 3749
              • 24,544 Posts
              Quote from: sottwell at Sep 07, 2010, 05:50 AM

              huh It’s just a plugin with the configuration option in its Configuration tab. I presume Revo also has configuration for its plugins?

              Yes and no. Plugins in Revo have a "Properties" tab -- essentially a grid of key/value pairs -- the equivalent of preset snippet parameters. They would work fine for this, but wouldn’t qualify as a UI. There’s probably a way to add a tab and populate it with more sophisticated configuration options (e.g., radio buttons), but I don’t know how to do it. I think you could also do it with a Custom Manager Page, but those are very time-consuming to do (at least for me).

              [update] Oops, I just checked and the properties now can be in the form of a drop-down list or Yes/No option in addition to strings and integers so there is a minimal UI there. Time to rewrite the book (yet again) -- sigh.
                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
                • 28215
                • 4,149 Posts
                From: http://rtfm.modx.com/display/revolution20/Form+Customization+Rules


                Rule Constraints are special abilities that let you restrict the Rule to a certain value on an object’s field. Let’s say you want to restrict a Rule for resource/update to only occur on Resource’s with a Template ID of 4. You’d simply set the Constraints like so:

                Constraint Class: modResource
                Constraint Field: template
                Constraint: 4
                  shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                  • 3749
                  • 24,544 Posts
                  Duh. I should have thought of that.
                    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
                    • 3749
                    • 24,544 Posts
                    This is close to what you want: http://rtfm.modx.com/display/revolution20/Field+Label except that the name will be "template," the rule will be "field default" and the value will be the ID of the desired template.

                    Then add the constraint from splittingred’s post above.
                      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
                      • 26401
                      • 247 Posts
                      I’m just a few days into revo at this point so this is all very helpful
                      I was curious if it is possible to achieve this(or something similar) using the property set