This tells MODX to load some base classes that we'll need – yes, we're sort of double-dipping here. Because our main class file is on MODX's radar and will be included when MODX loads, we just can require more files from there. At the bottom of the same file, after your CopyrightedResource class, put this:

Now we've overridden the processors for our class; MODX will automatically use these classes as the processor class when creating or updating our CRC. We can then override methods to provide custom functionality for our CopyrightedResource class. For example, here is a stub for our CopyrightedResource class and the Update processor that shows some methods that you could override:

These are just trivial examples, but hopefully you get the idea. If you've been paying close attention to our examples on these pages, you may have noticed that we set some properties in the CopyrightedResource class (class_key), and we set others in CopyrightedResourceUpdateProcessor (cacheable, isfolder). This may leave you confused as to where you should modify a behavior – in the resource child class? In the controller class? or in the processor?

If the attribute is something that can be controlled by the GUI, then you'll have to do some customizations in the processors.

Extra Attributes

There are some attributes that are not in the modx_site_content table. See the comments in the modresource.class.php file for a list of attributes. You can set them in your resource class via the set method, e.g.:

You can customize the icon used in the MODX resource by creating a System Setting named after your custom resource class: mgr_tree_icon_ + strtolower($class_key). Set its value to CSS class that will be used.

Conclusion

And that's about it! There's obviously tons of possibilities with CRCs, and you can really go nuts on the customization that you can apply to them and their processing and rendering logic. Have fun!

Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).

Looking for Something?

Pro Tip: Use the "f" and "esc" keyboard shortcuts to open and close search