
GeoLocation2
MODX geodata — gl_* catalog, SxGeo, city picker modal, REST action.php


In System → System Settings → geolocation2 set:
| Key | Recommended for start |
|---|---|
geolocation2_detect_method | sxgeo — detect by IP on first visit |
geolocation2_debug | 0 in production, 1 while debugging |
Details: System settings.
In <head> or before </body> add initialization (CSS/JS and Bootstrap 5 if not already on the page):
{'!GeoLocation2Initialize' | snippet}[[!GeoLocation2Initialize]]Parameters loadBootstrap, loadCss, loadJs — see GeoLocation2Initialize.
In header or footer:
{'!GeoLocation2Current' | snippet : [
'tpl' => 'tpl.GeoLocation2.current'
]}
{'!GeoLocation2Modal' | snippet}[[!GeoLocation2Current? &tpl=`tpl.GeoLocation2.current`]]
[[!GeoLocation2Modal]]Chunk tpl.GeoLocation2.current ships with the package. Use data-gl2-open="1" on the button to open the modal.
$_SESSION['gl2'].GET /assets/components/geolocation2/action.php?action=state (with X-Requested-With) returns JSON with state, confirmed and session fields.If you filled gl_data in the manager:
{'!GeoLocation2Data' | snippet : [
'forCurrent' => 1,
'tpl' => 'tpl.GeoLocation2.data.current'
]}[[!GeoLocation2Data? &forCurrent=`1` &tpl=`tpl.GeoLocation2.data.current`]]Next: Integration, Web API, FAQ.