We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39333
    • 151 Posts
    I am neck deep in the form customization area and wanting to remove the template selector for a number of templates.

    I have the templates in an element category and used many ACL rules, 7 on create and 7 for update, to make it not visibile.

    So my question is, is there an easier way than having all these rules? I tried making 2 rules, one for create and one for update, and adding in all the template IDs within the constraint and template in constraint field, ID's comma separated. However it only took the first value and ignored the rest.

    I see that it adds modResource.contraint. I tried putting "category" and the element category name and also the number into the constraint field which did not work also. I imagine because of the modResource is not the correct object model for those settings to work.

    I also tried doing the reverse, since there are less templates I want shown than hidden. By setting all to hidden, then a separate rule, create and update, for each I want to show. This did not work and all stayed hidden.

    Does someone have a plugin written, or could give me a sample of one that would work, to custom do this? The best method I think is to have the template selector hidden that fall into the protected element category.

    Thanks
      MODX...the Zen of CMS
      "Bight off more than you can chew and keep right on chewing."
      • 39333
      • 151 Posts
      I looked in the repository and didn't turn up anything. What system events should I be looking for to accomplish this?
        MODX...the Zen of CMS
        "Bight off more than you can chew and keep right on chewing."
      • Something like this (inspired by MovePublished) should work as a plugin triggering on OnDocFormPrerender:

        $extjs = "<script type=\"text/javascript\">
        MODx.on('ready',function() { 
          if (Ext.getCmp('modx-resource-template')) { 
            Ext.getCmp('modx-resource-template').hide()
          }
        });
        </script>";
        $modx->regClientStartupHTMLBlock($extjs);
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 3749
          • 24,544 Posts
          Mark, he just wants to hide some of the template options, not the whole template selector. It's quite tricky because they don't exist until added when you click on the drop-down. I tried connecting an on-click function to the template selector, but didn't have any luck with it.
            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
            • 39333
            • 151 Posts
            Mark, he just wants to hide some of the template options, not the whole template selector. It's quite tricky because they don't exist until added when you click on the drop-down. I tried connecting an on-click function to the template selector, but didn't have any luck with it.

            So same trouble there as with the empty option Bob? It got wordy but I am just trying to find an easier way to hide templates from the selector than having to create 2 Sets for each template I want hidden. Not a big deal with a small site but with a lot of templates this method is tedious. Especially if you decide to update some of the form. You'd have to go to each and every Set or create all new ones.
              MODX...the Zen of CMS
              "Bight off more than you can chew and keep right on chewing."
              • 3749
              • 24,544 Posts
              If anyone would know how to do it, Mark would.
                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