We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39932
    • 483 Posts
    Fuzzical Logic Reply #1, 14 years ago
    Property Sets are pretty darned neat. There are many ways in MODx to limit how much you have to code to make it work, but Property Sets are among the best of them. You can attach a Property Set to any Element and set the properties according to your needs. This means that you no longer have to type them out, and it keeps your Templates, Chunks, etc, very clean and easy to read. Best of all, you can still use the Property Set, and override any of the properties you set by still typing them out. Now, here's something that isn't often mentioned....

    If you don't ever go into the Tools -> Property Sets to make your Property Sets, you might have missed this. Try and do so now... On the left of the main screen, you'll see the Sets. If you expand them, you'll see the Element(s) that are attached to the Set. If you right-click on the Set, you can "Attach Element to Property Set". This means that you can attach multiple Elements to the same Property Set. If they share Properties, they can use (all or some of) the same values. This can be great for a lot of reasons and has a lot of applications.

    Here's a few examples:

    • You can set up which Set to use via a System Setting (Context or User, as well)
    • You can use a TV for page related Property Sets
    • You could make Template-wide Property Sets
    • You could pass the Property Set via Placeholder...
    • Using any of the above, you can develop your Snippets, etc, separately from the working site and then activate them by simply Setting the appropriate value. No code changing!

    Here's what I mean:
    // This is allowed!
        [[!mySnippet@[[*whichSet]]]]
    // This will grab the same Property Set, but for the Chunk instead.
        [[!myChunk2@[[*whichSet]]]]
    
    // This is an override
        [[!myOverridden@MySet? &p1=`1`]]
    // Here is another one!
        [[!myOverridden@[[++whichSet]]? &p1=`1`]]
    


    Some notes on Tools -> Property Sets:

    This is, IMHO, the best place to add Property Set and Attach Elements and adjust the associated Properties. While you can do this on the Element itself, if you use the same Property Set, you may run into issues that you might have a hard time debugging. This is especially true if both utilize some of the same script properties or placeholders but are not necessarily listed as Properties. (This happens often in Snippets)

    When adjusting these Properties, do so by selecting the actual Element first. The Property Set, itself, does not need all of the Properties for all Elements on it, but adds them to itself, by default. In cases where you want to share values, keep them in the specific Property Set page. In cases where the Properties must be different (but in the same set) remove them from the Property Set page and change them in the individual elements.

    Properties have a color indicator: Purple means that it is a custom Property for that element (this means that it is not defined by the element, not necessarily that it is or is not used). Green means that you have changed the value for the Property. Black means that it is a default Property with a default value.

    You may delete any Purple Property from an Element's Property Set. Simply Right-Click on the Property and choose "Delete Property". You may delete any Property from a Property Set itself. You may not delete any Property from an Element's Property Set if it is part of that Element's default set, but you can remove the value. [ed. note: fuzzicallogic last edited this post 14 years ago.]
      Website: Extended Dialog Development Blog: on Extended Dialog
      Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
      Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

      Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
      • 3749
      • 24,544 Posts
      This is the opposite of the advice I usually give, but you make some very good points. I usually advise creating the set on the Properties tab of the element because then it's automatically attached to the element (something that's easy to forget to do and difficult for beginners to debug -- they specify the set in the tag and can't figure out why it's not being used).

      I think the interface on the element's Properties tab is a little more intuitive for beginners too, but that's arguable. I think most users don't have any property sets attached to more than one element (though, as you say, it's quite handy). I could be wrong about that.

      I think I might say that Tools -> Property Sets is the best place to create and work on your property sets *if* you have any property sets that are attached to more than one element. Of course the great thing about MODX is how many cases there are where you get to work the way you prefer.




      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 39932
        • 483 Posts
        Fuzzical Logic Reply #3, 14 years ago
        Thanks for the comments!

        I think the interface on the element's Properties tab is a little more intuitive for beginners too

        That's a great point and I definitely agree with you, which is why I gave a careful explanation of how to use the Tools -> Property Sets. I think this Tip is more for people who are already familiar with MODx and Property Sets but want to get the most out of them. I could be wrong, but I don't see "true beginners" to the platform utilizing this tip. For those brand new to MODx, I would probably initially give them the same advice.

        I think I might say that Tools -> Property Sets is the best place to create and work on your property sets *if* you have any property sets that are attached to more than one element.

        Given the above, I'm still inclined to stick to my statement. This is mostly because a little extra knowledge never hurt anyone (except the cat). And while the other method is a little more intuitive, Tools -> Property Sets is not that much less intuitive.

        Of course the great thing about MODX is how many cases there are where you get to work the way you prefer.

        It's so incredibly true!! Working in MODx is so much cooler than working in more rigid systems.
          Website: Extended Dialog Development Blog: on Extended Dialog
          Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
          Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

          Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          (something that's easy to forget to do and difficult for beginners to debug -- they specify the set in the tag and can't figure out why it's not being used).
          One reason why this may be so easy for beginners to "forget" is because it was never specifically mentioned in the rtfm. I've remedied that.

          From Tools -> Property Sets, right-click on the property set and choose "Attach Element to Property Set". First select the Class Name of the element, then select the element itself. You can attach multiple elements to the same Property Set.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org