Skip to content

Instantly share code, notes, and snippets.

@shectermen
Created June 29, 2015 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shectermen/da2b27f21a7159ec545d to your computer and use it in GitHub Desktop.
Save shectermen/da2b27f21a7159ec545d to your computer and use it in GitHub Desktop.
<?php
/*Массив с параметрами для получения значения ем параметра*/
$where = array(
'contentid' => $id
, 'tmplvarid' => 11
);
$tv = $modx->getObject('modTemplateVarResource', $where);
/*Записываем в переменную значение из TV */
$result = $tv->get('value');
/*Переворачиваем координаты*/
$revers_coords = explode ("," , $result);
/*URL с запросом на yandex*/
$city="https://geocode-maps.yandex.ru/1.x/?geocode=".$revers_coords[1].",".$revers_coords[0]."&city&results=1";
$city_xml = file_get_contents($city);
preg_match('/<LocalityName>(.*?)<\/LocalityName>/',$city_xml,$city_point); // вырезаем нужные нам координаты для метро
$resource -> setTVValue('city', $city_point[1] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment