You can use this project called ‘Decorate‘, to add various features to your CakePHP baking process which are not available with this version of bake.php.
It can add 3 important features for you:
1. Pagination (very handy)
2. filtering(search)
3. complex sort
Also take a look at a detailed explanation here.
I found CakePHP to be helpful with a lot of things and I loved the fact that anyone can reuse any classes made in PHP using 'vendors' in CakePHP. We recently wrote a CakePHP helper for generating map in CakePHP application.
The helper uses Google Maps API V2 class from phpinsider.com.
To begin with, just download the class and place them inside 'vendors' folder.
Here's the code for the helper: map.php
PHP:
-
<?php
-
class MapHelper extends Helper
-
{
-
-
var $helpers =
array('Html');
-
-
function displaymap($locations=false,$width=500,$height=500)
-
{
-
vendor('GoogleMapAPI.class');
-
$map = new GoogleMapAPI('map');
-
if($locations)
-
foreach($locations as $location)
-
{
-
$map->
addMarkerByAddress( $location['address'],
strip_tags($location['title']),
$location['title']);
//adds address to showup in Map
-
}
-
else
-
{
-
$map->setCenterCoords(-96.67,40.8279); // if no locations are passed in function, then focus on US
-
$map->setZoomLevel(3);
-
}
-
-
$map->setWidth($width);
-
$map->setHeight($height);
-
$map_content=$map->getHeaderJS().$map->getMapJS().$map->getMap();
-
return $this->output($map_content);
-
}
-
}
-
?>
Here's the code for the view (index.thtml in my case): index.thtml
PHP:
-
<? php
-
// initialization of $my_locations array to show in map
-
-
$my_locations[1]['address']='621 N 48th St # 6 Lincoln NE 68502';
-
$my_locations[1]['title']='PJ Pizza';
-
-
$my_locations[2]['address']='826 P St Lincoln NE 68502';
-
$my_locations[2]['title']='<b>PJ Pizza</b>';
-
-
echo $map->
displaymap($my_locations,
500,
500);
?>
-
<script type="text/javascript">onLoad();</script>
While working on a real estate CMS, I realized that Google Maps API is having some legal issues in providing geocode data for UK, Japan or China. The call to API is failed with code 603 (G_GEO_UNAVAILABLE_ADDRESS) indicating that legal or contractual reasons prevent Google from returning the information. At first, I realized that we might have to drop the idea of Google Maps, but after a quick test with Yahoo Maps, i found Yahoo to be working fine with UK.
I never wanted to use Yahoo Maps, so i come up with this solution:
In order to run Google Maps for UK, you have to extract geocodes using Yahoo API, and then pass same geocodes to Google Maps.
Here's the Yahoo URL which return the geocode:
http://api.local.yahoo.com/MapsService/V1/geocode?appid=[your_app_id]&location=6%20Salisbury%20Square,%20LONDON
Just call Yahoo API for the data at place where you're requesting google.com, and pass on the geocodes to GoogleMap. And you're done !!
I found out a lot of people asking about this, so I decided to write a small post here, if anything needed in details, please post your comments.