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

cfCities snippet ​

Snippet for outputting the current city, city list and city selector. On call it includes the CSS and JavaScript files specified in the component system settings.

Snippet output

Parameters ​

NameDefaultDescription
&tplcfCities.rowRow chunk
&tplWrappercfCities.outerWrapper chunk for all results. Understands one placeholder: [[+rows]]
&selectedselected="selected"If current city, this value is written to placeholder [[+selected]]
&whereJSON-encoded array of additional query parameters
&sortbyidCity field to sort the list by. Available: id, key, name
&sortdirASCSort direction: DESC or ASC
&limitMaximum number of results

Call examples ​

To use the component, call the snippet uncached anywhere on the site, with no parameters:

modx
[[!cfCities]]

To sort cities alphabetically:

modx
[[!cfCities?
  &sortby=`name`
]]

To output only certain cities, use the where parameter:

modx
[[!cfCities?
  &where=`{"name:IN":["Moscow","Saint Petersburg","Yekaterinburg","Tyumen"]}`
]]

Or limit the number of results:

modx
[[!cfCities?
  &limit=`12`
]]