> I'm putting together a project that has a list of product categories on
> the top of several pages. The categories are stored in the database
> (model ProductType). Now I'm thinking the best way to do this is to
> make the part that displays the HTML a element view and then figure out
> how to use a component to feed data to that element for display. Is
> this the best way to do this or is there another way that this is
> commonly done?
create the element, then use request action to pass the data to it, eg:
// /elements/product_categories.thtml
foreach ($data as $row)
{
echo $row['name'];
}
// in a view
echo $this->renderElement ('product_categories',
array('data'=>$this->requestAction ('/products/list_categories'));
// in ProductsController
function list_categories ()
{
return $this->Product->ProductCategories->generateList ();
}
you could also put the call to requestAction in the element, to make
it more self contained
hth
jon
--
jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---