MODX Quick-Tip: Getting and Setting Resource Properties

#MODX Quick-Tip: Getting and Setting Resource Properties

Dec 23, 2015

The Low-Down

The MODX Resource object has a secret-not-secret field, properties in which you can store a JSON object with any kind of (serialized) data you like. However, there's no UI with which to edit that field. Below are some embedded Gists, for a Plugin and Snippet, that can help you utilize this lesser-known feature.

setResourceProps Plugin

Here's an example:

Note the data that this Plugin saves, is specific to a certain use case: storing the Resource IDs of those published just previous, and just after, the current Resource. If you want to store other data in Resource properties, modify it as needed.

getResourceProps Snippet

This Snippet fetches properties from a given namespace and sets placeholders with the values: