Skip to content
  1. Extras
  2. GeoLocation2
  3. Snippets
  4. GeoLocation2Current

GeoLocation2Current

Shows the city the component treats as current: from session, SxGeo (before session exists), or default row in gl_cities. Uses buildWebPlaceholders() from the GeoLocation2 service.

Parameters

ParameterDefaultDescription
tpltpl.GeoLocation2.currentHTML chunk
asJson0Return JSON of gl2_* placeholders instead of chunk
toPlaceholder0Write output to placeholder

Call

modx
[[!GeoLocation2Current]]
[[!GeoLocation2Current? &tpl=`tpl.GeoLocation2.current`]]
[[!GeoLocation2Current? &asJson=`1`]]
fenom
{'!GeoLocation2Current' | snippet}
{'!GeoLocation2Current' | snippet : ['asJson' => 1]}

gl2_* placeholders

Available in chunk and JSON when asJson=1:

PlaceholderMeaning
gl2_current_idCity ID in gl_cities
gl2_current_name_ruName (RU)
gl2_current_name_enName (EN)
gl2_display_name_ruName in modal question (may use SxGeo)
gl2_real_name_ruCity from SxGeo
gl2_default_id / gl2_default_name_ruCity with default flag
gl2_confirmed / gl2_prompt_done1 after user confirmed
gl2_csrfToken for POST to action.php

Default chunk output

tpl.GeoLocation2.current:

html
<span class="gl2-current-city" data-city-id="1" data-confirmed="0">Moscow</span>

data-confirmed="0" until modal confirm, "1" after.

Custom chunk: button with data-gl2-open="1" to open GeoLocation2Modal.

JSON example (asJson=1)

json
{
  "gl2_current_id": "1",
  "gl2_current_name_ru": "Moscow",
  "gl2_confirmed": "0",
  "gl2_csrf": "a1b2c3…"
}

See GeoLocation2Modal, Web API.