Archive for November, 2009

AJAX pagination with jQuery and elements

A simple way to get your paginated data in your view through ajax with jQuery. Thanks to Cesay Dreier and his article at the bakery http://bakery.cakephp.org/articles/view/easy-ajax-pagination-using-jquery.

I changed the code a bit because I use elements in an extensive way. So here is almost the same code but now with an element and some updated javascript code.

I used the latest CakePHP 1.2.5 and did nothing to the layout. So the classes or id’s will be of the default CakePHP layout. I added the blog tutorial posts table and some data.

1. Add to your controller (or AppController):

// my posts controller looks like this
class PostsController extends AppController {
	var $name = 'Posts';
	var $components = array('RequestHandler');
	var $paginate = array('limit' => 10);

	function index() {
		$this->Post->recursive = 0;
		$this->set('posts', $this->paginate());
	}
}

(more…)

Amazon eCommerce datasource

Amazon eCommerce APII just pushed the Amazon eCommerce API datasource to gitHub: http://github.com/primeminister/CakePHP-Amazon-eCommerce-datasource

With this datasource you can easily get listings and items from Amzon in the books, music, etc categories.

You need an access key and secret key from http://aws.amazon.com. Please see the README file in the repository and check the Amazon API at http://docs.amazonwebservices.com/AWSECommerceService/2009-10-01/DG/

Please fork the code if you have optimizations, suggestions, etc. or leave a comment.