Yes, you've got the categories/products thing set up as I would do it. With ordering, you can do it both ways:
1) Just for this association - use the 'order' key when setting up the association in categories model... eg. http://book.cakephp.org/view/78/Associations-Linking-Models-Together#Relationship-Types-79 2) Globally - add it into the products model. var $order = 'Product.name DESC'; Cheers, Adam On Dec 31, 7:31 am, Daniel <[email protected]> wrote: > 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 [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?hl=en -~----------~----~----~----~------~----~------~--~---
