I have cars controller, Car model and views for cars.

I am using Twig 1.0, 
http://www.twig-project.org/doc/templates.html#list-of-control-structures
Cake 1.3

I want to do the following in the controller:

function index() {

...

$carData = $this->Car->find('all');

$cars = Car::prepareForView($carData);

$this->set('cars', $cars);


}

the prepareForView will turn the car data into an object that
implements the IteratorAggregate 
http://php.net/manual/en/class.iteratoraggregate.php

the reason is because i want to be able to do the following in the
view using Twig.

{{ cars.size }} // returns me the size
{{ cars.first }} // returns me the first element of the array
{{ cars.last }} // returns me the last element of the array

Am i right in wanting to prepare the array as an IteratorAggregate?
If i do this for Car and other models, how should i do it?

Advice, please. Thank you.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to