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

GeoLocation2Modal

Renders Bootstrap 5 modal and “Your city” toolbar. Uses session, CSRF and action.php. Sets gl2_* placeholders on the page (used by GeoLocation2Current and Fenom).

Load GeoLocation2Initialize before the modal, or pass includeAssets=1 (legacy single-snippet mode).

Parameters

ParameterDefaultDescription
tpltpl.GeoLocation2.modalModal + toolbar chunk
itemTpltpl.GeoLocation2.modal.itemCity row in list
modalShow1Auto-show on first visit
includeAssets0Inline CSS/JS from this snippet
loadBootstrap0Bootstrap 5 CDN (with includeAssets=1)
preferRealWhenDefault1Show SxGeo name in question when default city
dismissSetsDefault1Close with X → default city
modalIdgeolocation2ModalHTML id
unknownCityLabellexiconUnknown city label
defaultCityLabellexiconDefault city label
toPlaceholder0Output to placeholder

Call

modx
[[!GeoLocation2Initialize]]
[[!GeoLocation2Modal? &modalShow=`1`]]
[[!GeoLocation2Current]]
fenom
{'!GeoLocation2Initialize' | snippet}
{'!GeoLocation2Modal' | snippet : ['modalShow' => 1]}
{'!GeoLocation2Current' | snippet}

Behavior

  1. Confirm step — “Your city — Moscow?” Buttons Yes (action=confirm) and Change (list step).
  2. List step — search field and city list. Search uses action=search for cached pages. Initial HTML also lists cities from DB (no-JS fallback).
  3. Toolbar below modal — current city and .gl2-open-modal link.

With modalShow=1 and gl2_confirmed=0, script opens modal after load.

Markup fragment

From tpl.GeoLocation2.modal (simplified):

html
<div class="modal fade geolocation2-modal" id="geolocation2Modal"
     data-gl2-root data-gl2-action-url="/assets/components/geolocation2/action.php"
     data-gl2-csrf="…" data-gl2-modal-show="1">

</div>
<p class="geolocation2-toolbar">
  <strong class="gl2-toolbar-city">Moscow</strong>
  <a href="#" class="gl2-open-modal">Change</a>
</p>

POST to action.php

ActionWhen
confirmYes on confirm step
savePick city from list
dismissClose via X or backdrop

Each POST needs csrf from data-gl2-csrf and header X-Requested-With: XMLHttpRequest.

See GeoLocation2Initialize, GeoLocation2Current.