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.]