We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19328
    • 433 Posts
    Hi there,

    Is it possible to hide (for example) the delete button from the row of save/duplicate/delete/view/close/help buttons you see at the top right of your screen for a specific resource? Anyone ever accomplished this?

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

      • 42562
      • 1,145 Posts
      I use CSS to hide them, and sometimes JS to remove them. These is superficial though.
      What are you trying to accomplish, security, aesthetics, etc?
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 19328
        • 433 Posts
        Well, this is what happens a lot: I have some GridClassKey containers with news resources in it. When a user wants to delete one or more news resources, they press on the checkbox them and they press the top right 'delete' button. This doesn't delete the resources, but the complete GridClassKey container. Fortunately I can recover them by undeleting them, but this happens a lot with my customers. So, that's why I'm looking for a way to hide the delete button on these GridClassKey containers.

        Would you like to share your solutions donshakespeare? smiley



          • 42562
          • 1,145 Posts
          Example, the TinymceWrapper Extra (plugin) runs when a resource is being edited.
          Now it is coming with a gallery, in this gallery I can't afford a user to use the native save/duplicate buttons.
          So I have a CSS code that is fired by the plugin
          #modx-abtn-save, #modx-chunk-header, #modx-abtn-help, #modx-abtn-cancel, #modx-chunk-msg, label[for="modx-chunk-snippet"], #modx-abtn-duplicate {
              display: none !important;
          }

          In your case, you'd write a small plugin that produces this kind of code. Done!
          Could even use JS to kill keyboard shortcuts and/or remove the buttons completely from the DOM.
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
          • discuss.answer
            • 19328
            • 433 Posts
            Thanks, that helped me! Here's my code to hide the delete button on any page which is a GridClassKey-container ('class_key' set to 'GridContainer')

            Create a plugin and select onDocFormRender
            Paste this code:

            <?php
            $class_key = $resource->get('class_key');
            if ($class_key == 'GridContainer') {
            $modx->regClientStartupHTMLBlock('
            <style>#modx-abtn-delete {display: none !important;}</style>
            ');
            }


            Or if you want to do this just for one resource, use:

            <?php
            $id = $resource->get('id');
            if ($id == 12345) {
            $modx->regClientStartupHTMLBlock('
            <style>#modx-abtn-delete {display: none !important;}</style>
            ');
            }


            And here are the ID's of the other buttons, if you want to hide them:
            #modx-abtn-save
            #modx-abtn-duplicate
            #modx-abtn-delete
            #modx-abtn-preview
            #modx-abtn-cancel
            #modx-abtn-help [ed. note: michelle84 last edited this post 10 years, 5 months ago.]
              • 42562
              • 1,145 Posts
              Very good stuff!
                TinymceWrapper: Complete back/frontend content solution.
                Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.