Skip to content
  1. Extras
  2. cityFields
  3. cfField snippet

cfField snippet

Snippet for outputting city-specific data by key. Each call runs a database query, which can slow page load if the snippet is used many times. In most cases it is better to use placeholders set by the cityFields plugin on page load.

Parameters

NameDefaultDescription
&keyPlaceholder name to output. Write without the prefix
&cityCurrent city IDCity ID, key or name for which to output data. Using key or name causes an extra database query

Call examples

The &key parameter is required. A typical call:

modx
[[!cfField? &key=`phone`]]

To output data for a specific city regardless of the current selection, add &city:

modx
[[!cfField? &key=`address` &city=`5`]]

The snippet can also be used as a Fenom modifier:

fenom
{'phone' | cffield} or {'address' | cffield : 5}