We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37210
    • 131 Posts
    Holy Jeesters guys. I am confused as all hell. I am trying to hide certain templates in the ’Uses Template’ drop-down menu from certain manager users in Revo 2.0.8-pl.

    I know that ManagerManager was able to do this quite simply in previous releases of MODx but I am having a heck of a time finding the solution for Revo. I have played around with ’Form Customization’ but to no avail. All I need is a tutorial or a step-by-step. Anyone know of anything like that anywhere?





    Here are some resources I have found so far just in case it would come in handy for someone else who knows what they’re doing:
    Bob’s Guides - http://bobsguides.com/revolution-permissions.html
    Topic: Revo most complicated permissions system - http://modxcms.com/forums/index.php/topic,62298.0.html
    Topic: MODx Revolution’s Cheatsheets - http://modxcms.com/forums/index.php/topic,48252.0.html
      • 3749
      • 24,544 Posts
      Form Customization will let you hide that field completely or set its default value, but it won’t let you control which templates are shown.

      I won’t promise that this will work, but I think it’s supposed to.

      Put the templates you want to hide into a category.

      Then go to Security -> Access Controls -> User Groups tab.

      Right-click on the Administrator group and select update.

      On the Element Category Access tab, create a new ACL entry specifying that category, a context of ’mgr,’ a minimum role of admin Super User, and a policy of ’element.’

      Save.

      Flush Permissions

      Flush All Sessions


      That should protect those templates (assuming that either your other users are not all admin super users or they are not members of the Administrator group).

      That will hide the templates in the tree, but I don’t know if hiding them in the drop-down is implemented yet. You may have to wait for 2.1.0-pl, I’m pretty sure it works there.

      As a last resort, I think it would be possible to hide the template drop-down completely with Form Customization, create a TV that would show the selected templates as a drop-down list, and write a plugin that would set the template from the TV value when you save the resource.
        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
        • 9990
        • 7 Posts
        Quote from: BobRay at May 19, 2011, 04:56 AM



        Put the templates you want to hide into a category.

        Then go to Security -> Access Controls -> User Groups tab.

        Right-click on the Administrator group and select update.

        On the Element Category Access tab, create a new ACL entry specifying that category, a context of ’mgr,’ a minimum role of admin Super User, and a policy of ’element.’

        Save.

        Flush Permissions

        Flush All Sessions


        This successfully hides the templates from the ’Uses Template’ drop-down menu, but it also hides the Template Variables, so their values can only be edited from the super user ... which is not so good shocked


          • 37210
          • 131 Posts
          Hey guys

          Thanks for your help. I have put permissions on the back burner for now. Thankfully, it’s not required for Go-Live!

          Bobray..I’ll have another go and follow your instructions.

          Fouk..If this is true, then I definitely need another method :S
            • 3749
            • 24,544 Posts
            That sounds like a bug. Could you report that using the Bugs and Requests link at the top of this page?

            In the meantime, you may be able to put the template variables in a separate category and give the users access to them with another Element Category Access ACL entry.
              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
              Old post but still relavent it seems. Is this still an active issue? Trying to achieve the same things and having the same results.

              This successfully hides the templates from the 'Uses Template' drop-down menu, but it also hides the Template Variables, so their values can only be edited from the super user ... which is not so good

              I am seeing the same results. Placing protected templates into their own category and attaching them to the admin group does indeed make the template variables tab disappear for standard users.

              In the meantime, you may be able to put the template variables in a separate category and give the users access to them with another Element Category Access ACL entry.

              I tried this adding all remaining categories into the standard user group category. This does not bring back the template variables tab.

              The only thing I have in the category protecting the select templates are those templates. Nothing else sitewide shares that category.

              Another problem I see is that when a standard user chooses a template from the short list available to them they can also choose none which screws up the page if they save it. For some reason this action cleared all current content in template variables even upon changing the template back to the correct one. They can also still change a template on a page which has a template they do not have access too. So while the template name is hidden the ID number does show and allow them to change to an unprotected template.

              So my question would be how is it possible to both have the template selector show on select resources and lock it from being changed on others?

              Revolution 2.2.6.pl traditional
                MODX...the Zen of CMS
                "Bight off more than you can chew and keep right on chewing."
                • 3749
                • 24,544 Posts
                There may be an easier way, but one way would be a plugin that prevented a change to the Template under certain conditions. I think I would probably check in OnBeforeDocFormSave, and if the conditions are met (e.g, not the admin user), just change the Template to whatever is in the DB. I'm not positive that would work, but I think it would.

                You can also put TVs into a Resource Group (though it's hard to find in the Manager), then give the users access to them with a Resource Group Access ACL entry. That might work, or not.

                  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
                  You can also put TVs into a Resource Group (though it's hard to find in the Manager), then give the users access to them with a Resource Group Access ACL entry. That might work, or not.

                  I fiddled around more with the groups and tried adding the TVs to the manager group. That gave me some weird results which opened up a whole slew of other questions without answers.

                  There may be an easier way

                  If you know it will you let me know?

                  As a last resort, I think it would be possible to hide the template drop-down completely with Form Customization, create a TV that would show the selected templates as a drop-down list, and write a plugin that would set the template from the TV value when you save the resource.

                  Is there a plugin to do this in your vast collection? There are only 2 resource types the end users need to be able to pick a template for to meet my requirements.
                    MODX...the Zen of CMS
                    "Bight off more than you can chew and keep right on chewing."
                    • 39333
                    • 151 Posts
                    There may be an easier way, but one way would be a plugin that prevented a change to the Template under certain conditions. I think I would probably check in OnBeforeDocFormSave, and if the conditions are met (e.g, not the admin user), just change the Template to whatever is in the DB. I'm not positive that would work, but I think it would.

                    I think I have the logic worked out. I'm going to give the plugin a whirl.
                      MODX...the Zen of CMS
                      "Bight off more than you can chew and keep right on chewing."
                      • 39333
                      • 151 Posts
                      @BobRay, Here's what I was thinking...

                      //if OnBeforeDocFormSave event
                      if ($modx->event->name == 'OnBeforeDocFormSave') {
                      
                        //if the category of the chosen template is 'Admin' and the current user belongs to group 'Manager'
                        //then block changing the resource template
                        //**really I would like to hide the 'Admin' group templates from view of any user in the 'Manager' group**
                        if (Admin($resource->template)) && (Manager($currentuser->group)) {
                          $modx->event->output('You can not change the template on this page.')
                          return '[templateSelector] Failed to save page id '.$id.' due to site Manager template change attempt');
                        }
                      
                        //also, if the current user is in the 'Manager' group and tries to change to empty template
                        //then block saving the resource
                        //**would prefer do not show empty template option for any user in group 'Manager'**
                        if (Manager($currentuser->group)) && (empty($resource->template)) {
                          $modx->event->output('You must choose a template for this page.');
                          return '[templateSelector] Failed to save page id '.$id.' due to site Manager empty template attempt');
                        }
                      
                      }


                      Am I on the right track?
                        MODX...the Zen of CMS
                        "Bight off more than you can chew and keep right on chewing."