Created
June 29, 2015 16:40
-
-
Save shectermen/da2b27f21a7159ec545d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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