I am new to CakePHP and started an application with it.
I am facing a problem how to better organize my view.
My application has Categories and Categories have related products.
in head I want to display all available categories and as user click on a Category name all it’s related product will be displayed under Categories list.
Should I define both Categories and Product show in a single view? or a view which extends these to view and where should I created these views? As these belong to 2 different models.
And how data will be feteched as I want to access product of only selected category not for all categories.
As you are new to cakePHP I would recommend to “bake” the controllers, models and views for your Categories and Products. When you bake them, you will be able to define the one-to-many-relation between both (Product
belongs_toCategory and Categoryhas_manyProducts).The result will be, that the Category-views automatically contain a list of related Products.
(You have to bake Category first and Product after that…)