What does it do?
This MODX Snippet consumes JSON (string or file) and, based on the specified properties, will build a string formatted for use in a MODX TV input options field. The result looks something like this:
Example Usage
To produce the result seen in the screenshot above, do the following in your MODX site:
- Create a Chunk with this Snippet call:
[[getTVInputsFromJson? &jsonFile=`http://schema.org/docs/tree.jsonld`]]
- Create a Single-Select TV with @CHUNK binding for "Input Options":
@CHUNK my_schema_tv_chunk
- Resources with the TV enabled will get a list of schema.org itemtype property values, like the screenshot above.
The Gist
The Snippet code is in a gist. More info can be found in the code comments. Happy MODX-ing!