We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8274 ☆ A M B ☆
    • 222 Posts
    This will sound crazy, but there is a need for it in a custom page I am creating.

    Outside of making a whole new Resource Type, is there a way, through including javascript in a Plugin, to remove the content field element from a Resource?

    here is the set up I am working with:
    I have a Manager Customization in place. I am putting TVs in the modx-above-content and modx-below-content panels. I want these to panels to stack side by side, which I could do by injecting some CSS via the regClientStartupHTMLBlock, but the Content element is getting in the way.

    These resources have no need for the content field as they essentially listings of parts.

    Before I walk down the path of Custom Resource Types, I thought I would attempt some alterations to an existing Resource Type.

    I did try to do some javascript to remove the element by id, this can't go in the HEAD as the element hasn't loaded yet, and for some reason registerClientHTMLBlock isn't inserting at the end (not doing anything, so I guess the FormRendering has something in it that block adding HTML to the end of the page).

    Any ideas? For now, I am hiding the content field with CSS, BTW.
      • 30585
      • 833 Posts
      To hide the content field, use Form customization (Manager Customization in MODX 2.3), uncheck modx-resource-content
        A MODx Fanatic
        • 8274 ☆ A M B ☆
        • 222 Posts
        That would work, but I am putting other elements in that region as stated in my explanation... using the modx-content-above and modx-content-below areas to put TVs in. turning the modx-resource-content off removes the entire content box. I just need to remove the content input field.

        I explored all that can be done in Form Customization and looking at javascript customization. Through customization and loading a custom CSS, I have been able to move TVs to the page setting region, below intro text and size them accordingly (TVs have a different margin/padding than Document Setting fields so they shift to the right about 10px by default).



          • 3749
          • 24,544 Posts
          Isn't hiding the content field good enough? Actually removing it might give the resource/update processor indigestion. Even if it doesn't, removing a DOM element with JS is tricky to implement and can cause memory leaks: http://stackoverflow.com/questions/8830839/javascript-dom-remove-element.

          Another option would be to just change the caption on the Content field via Lexicon Management or Form Customization and use it for something else.
            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
            • 8274 ☆ A M B ☆
            • 222 Posts
            That is what I am resolving as well. Make it 1px wide via css (so that the above and below panels can sit side-by-side) and display:none it.

            As with everything in MODX, just wanted to see what other ways of achieving this were out there before I make this a go.