// Getting child resources of the current resource id
$childResources = $modx->getCollection('modResource', array('parent' => $resource->get('id')));
$countrySortedResources = array();
$postcodeSortedResources = array();
// Store resources in two array depending on their TV value
if (!empty($childResources)) {
foreach($childResources as $childDoc) {
if ($childDoc->getTVValue('youCustomTV') === 'country') {
array_push($countrySortedResources, $childDoc);
}
else if ($childDoc->getTVValue('youCustomTV') === 'postcode') {
array_push($postcodeSortedResources, $childDoc);
}
}
}
// Then you can do what you want with the two arrays $countrySortedResources and $postcodeSortedResources
$modx->runSnippet('getResources', array('parents' => $resource->get('id'), 'debug' => '1', 'tvFilters' => 'yourTV==country'));
Hi comp_nerd26,
i think i just added an extra with your needs. It is called GoogleStoreLocator and will sort Resources by Distance on getting the address via TVs and using the Google-API for calculations.
Here is the link to the documentation: http://www.quadro-system.de/modx-extras/googlestorelocator.html
I just submitted the extra to the MODX-Package-Manager and waiting now for the validation. So i think it will show up in the next days. If you already want to give it a try, just click the download-button on the doc-page.
I hope this extra will fit your needs.
PS: @BobRay thanks a lot for that nice extra "mycomponents". Makes building an extra very easy.
best regards
Jan
Quote from: quadro at Nov 28, 2015, 06:30 AMHi comp_nerd26,
i think i just added an extra with your needs. It is called GoogleStoreLocator and will sort Resources by Distance on getting the address via TVs and using the Google-API for calculations.
Here is the link to the documentation: http://www.quadro-system.de/modx-extras/googlestorelocator.html
I just submitted the extra to the MODX-Package-Manager and waiting now for the validation. So i think it will show up in the next days. If you already want to give it a try, just click the download-button on the doc-page.
I hope this extra will fit your needs.
PS: @BobRay thanks a lot for that nice extra "mycomponents". Makes building an extra very easy.
best regards
Jan
HI
this is a great add-on for modx. just exactly what i was looking for. A couple of questions.
1) can the select option values be changed from km to miles? if i change it, will the add-on convert from km to miles?
2) On some of our static pages, we have for example lots of static pages 'locations in london', or 'locations in manchester' can the add-on be changed so that it can produce a list without the need of using the form, but as well other pages will also have the form.
&location=`City`
if (!empty($_REQUEST['location']) || isset($location) && !empty($location)){
$address = (isset($_REQUEST['location']))?str_replace(' ', '+', $_REQUEST['location']):$location;
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false');
$output = json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$lng = $output->results[0]->geometry->location->lng;
$radius = isset($_REQUEST['radius'])?(int) $_REQUEST['radius']:$defaultRadius;
//Centering Map to Position
$lat_center = $lat;
$lng_center = $lng;
$zoom = $zoom_search;
//Get Filtered Stores
$stores = filterStoresByDistance($stores, $radius, $lat, $lng, $unit);
}