We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36669
    • 12 Posts
    Do categories have any technical/functional background or are they only for visual organization?
    (just found out, I can’t have two same-named chunks in different categories)
      • 34147
      • 28 Posts
      They organize TVs within tabs on the resource page’s TV tab. So possibly it could be a conflict if you created two similar categories then tried accessing a resource where these two categories would be called. Since they don’t get a unique ID, it could be a redundancy call?
        • 3749
        • 24,544 Posts
        In Revolution, they are also used for security permissions.

        You can hide or show elements in a particular category based on the user group the user belongs to.

        In the future, they may also be used to fine-tune Form Customization rules and apply them only to elements in certain categories.
          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
          • 36669
          • 12 Posts
          I think, it would be cool if there was some kind of "scoping" so you wouldn’t need to have long and unique names (such as mytemplate_mypagetype_myarea) for all TVs and chunks.
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            Hmm.... from a database standpoint, it makes good sense to require a unique key for the name of each name, so I can understand the current limitations. Maybe it would be possible in the future to prepend the name with a prefix, or in MySQL to use a multi-column key. Taxonomies in MODx in general are still developing, so I suspect there will be a better organizational tool eventually.
              • 36669
              • 12 Posts
              Well, from what I’ve seen so far, these tables already have a numeric primary key that can be used for unambiguous identification.
              There would have to be an algorithm going up the category hierarchy and returning the first match for a name.
              From a performance standpoint the algorithm should run at save-time rather than view-time, from a standpoint of complexity/database space probably the other way round.
              But maybe I’m just building cloud-castles and this is technically unrealistic.
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                Yes, the tables include an integer primary key, but that’s not usually how those items are called. A Chunk is called via its name, e.g. [[$myChunk]], not [[$123]]. Any algorithms could compound to significant calculation-times, so your idea of doing it when an item is saved is a good one: that’s how hierarchical URLs are calculated I believe. I’m having trouble mentally imagining what the database query would have to look like if the query had to figure out which category a given chunk was in: when the chunk is called, it’s called by its name alone, regardless of what category it’s in.
                  • 36669
                  • 12 Posts
                  Quote from: Everett at Aug 02, 2011, 11:56 AM
                  A Chunk is called via its name, e.g. [[$myChunk]], not [[$123]].
                  Of course. The idea was to allow duplicate names and have a algo such as
                  while not at root level
                  {
                     if item with this name exists in current category
                        return item
                     go up one category level
                  }
                  return nothing/error


                  So I could name the chunk containing the footer bar "footer" in each of my templates and it would pick the right one each time (as long as I nicely sort them into categories)
                    • 9207 ☆ A M B ☆
                    • 2,475 Posts
                    I’m not following you there... how would the parser know what category it’s in? Based on the template? Or something else? So if the template is in the ’abc’ category and it encounters a [[$footer]] chunk, it should first look for a chunk named "footer" inside the ’abc’ category?

                    I think the usage is more simplistic than having a PHP loop... I think it’s literally as straightforward as something passed verbatim to a MySQL query, e.g.:

                    SELECT snippet from modx_site_html_snippets WHERE name='footer';


                    (i.e. database driven, not PHP- or logic-driven).
                      • 36669
                      • 12 Posts
                      Quote from: Everett at Aug 02, 2011, 12:39 PM
                      I’m not following you there... how would the parser know what category it’s in? Based on the template? Or something else? So if the template is in the ’abc’ category and it encounters a [[$footer]] chunk, it should first look for a chunk named "footer" inside the ’abc’ category?
                      Exactly, based on the category, the template/chunk/.. containing this particular inclusion-tag is in.
                      I think the usage is more simplistic than having a PHP loop...
                      No doubt. But it hasn’t got the beauty of context-sensitive name lookup, leading to name-clashes (resp. to artificial namespacing in the style of mytemplate_mypagetype_myarea).