Tuesday, December 30, 2008

Order associated data

Hi, me again, I hope you don't mind me coming back with another
question.

I'm not sure if I'm going about this the best way or not, so some
general advice would be handy.

I've got two models: Category and Product, Product belongs to
Category, with Category having many Product (with me so far?).

I'm using the view function within the Categories controller to list
the products displayed within that category. I'm using the read()
function to pull the data from the Category model, which of course is
pulling with it data from the associated Product model - which I'm
then just using a simple foreach ($category['Product'] as $product) {}
to display within the view.

Two questions - first, is this the best way of displaying products
within a specific category.

Second - is there anyway to change the order of the $category
['Product'] array, so that it's ordered by a field other than the id.

Thank you

- Daniel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: