MODX Quick Tip: TV Input Options from JSON (

#MODX Quick Tip: TV Input Options from JSON (

Feb 16, 2016

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: CMS Input Options

Example Usage

To produce the result seen in the screenshot above, do the following in your MODX site:

  1. Create a Chunk with this Snippet call:
[[getTVInputsFromJson? &jsonFile=``]]
  1. Create a Single-Select TV with @CHUNK binding for "Input Options":
@CHUNK my_schema_tv_chunk
  1. Resources with the TV enabled will get a list of 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!