We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 436 ☆ A M B ☆
    • 265 Posts
    Over the past few days I’ve dived straight into some deep Access Control and Form Customisations in Revo, one thing which I’ve not yet understood is what the new Class Key in each Resources Page Settings is for; but default set to "modDocument":



    I’ve looked through the main documentation and found nothing for "Class Key" or "modDocument", but in the API pages I’ve found a huge list of other modSomething’s, including modResource which is used when creating custom rules when doing Form Customisations - does this mean that I could create a rule with a contraint targeted at one document using modDocument then the Constraint Field to its ID, or something like that?



    I tried changing one Resource’s Class Key to something unique, e.g. modDocumentHomepage, with the intent to single out this resource and then target it with a constraint - but instead it completely vanished from the Manager (and I had to go into the database and change modDocumentHomepage back to modDocument)

    So I’m a bit baffled as to what the Class Key’s purpose is?

    Does anybody know a way to target just one Resource with a Form Customisation rule? As that would be pretty useful.
      MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.
      • 28215
      • 4,149 Posts
      splittingred Reply #2, 16 years ago
      Class Key is the class key of a Resource; currently there’s only:

      - modDocument (for normal Resources)
      - modSymLink
      - modWebLink
      - modStaticResource

      This field has been changed to a combo-box in the upcoming 2.0.4, with limited values. Changing it allows you to change the type of a Resource quickly (from WebLink to SymLink, for example). In the future, when we add full support for custom Resource types, this will be even more useful.

      As for the FC rule question per Resource, yes: use a constraint:

      Constraint Class: modResource
      Constraint Field: id
      Constraint: 123 (the id of the resource)

      You could also use constraints to apply an FC rule to, say, only Symlinks:

      Constraint Class: modResource
      Constraint Field: class_key
      Constraint: modSymLink

      Constraints offer all kinds of fine-grained control. 2.0.4 will introduce a ’For Parent’ option that allows you to have more control on resource/create pages exactly *what* field is targeted in the constraint.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 14883 ☆ A M B ☆
        • 450 Posts
        Quote from: splittingred at Oct 05, 2010, 03:49 PM

        This field has been changed to a combo-box in the upcoming 2.0.4, with limited values. Changing it allows you to change the type of a Resource quickly (from WebLink to SymLink, for example).

        Sorry to hijack this thread (ok, no, not really sorry) - but I thought I’d offer a real-world example of when changing the resource type is useful. On our site we are building large/comprehensive menus with lots of links to pages that aren’t yet converted to MODx. Rather than hard-coding those URLs into the menus, I’m creating them as WebLink resources and using the [[~id]] link syntax in the menus. Then when the time comes to pull one of those "external" pages into MODx, I’ll just change the class key from modWebLink to modResource, save & edit the page. No need to hunt through the menus and change the links.

          • 3634
          • 19 Posts
          Quote from: splittingred at Oct 05, 2010, 03:49 PM

          Class Key is the class key of a Resource; currently there’s only:

          - modDocument (for normal Resources)
          - modSymLink
          - modWebLink
          - modStaticResource

          What if I would like to work with a specific type of document and I will extend modDocument or modResource and have my modNewDocument is there a way to add it to the class key available list and also will the manager be able to build the update form for it?

          I am using MODx Revolution 2.0.5-pl (traditional), thank you.
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: bluehipy at Dec 27, 2010, 07:36 AM

            What if I would like to work with a specific type of document and I will extend modDocument or modResource and have my modNewDocument is there a way to add it to the class key available list and also will the manager be able to build the update form for it?
            Quote from: splittingred at Oct 05, 2010, 03:49 PM

            In the future, when we add full support for custom Resource types, this will be even more useful.
              • 17499 ☆ A M B ☆
              • 872 Posts
              Do you have any idea when Custom Resource Types is going to be available ?

              Will we be able to provide custom UI for them in the resource tree as well ?

              Example scenario:

              I create two new CRT: modBlog & modArticles, The modBlog Resources are shown with a custom icon in the resource tree, and if i click on it, instead of loading all the usual UI with all predefined fields, it loads a paginated grid with the list of modArticles.

              In the mean times the i would want the modArticles Resources to not be shown in the document tree and can only be child of modBlog Resource Type, and can’t have children.

              modBlog can have normal children (modDocument, etc...) but only modArticles are listed in the grid, other Types are shown as usual in a hierarchic view.

              Possible scenario ?
                • 17499 ☆ A M B ☆
                • 872 Posts
                I checked the official Roadmap, there are no mention of Custom Resource Types.
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: lossendae at Feb 18, 2011, 01:16 PM

                  I checked the official Roadmap, there are no mention of Custom Resource Types.
                  The capability is already there for the most part—it just requires the inclusion of a modResource derivative class, a custom controller and/or a custom processor to implement one. That said, how it fits into the manager UI is somewhat unexplored territory, depending on the scope of your derivations. This will need to be documented and likely things modified in core to accomodate the requirements that get identified from those who attempt to implement Custom Resource Types first.