Reputation: 1885
I have an order processing and catalog system created in CakePHP. It manages orders, products, packages, invoices, etc. (anything that would be necessary for an ecommerce store basically).
I now want to make a "dashboard"-type page, that will show the latest orders, products that need to be updated, latest reviews, etc. I was going to create a Page for PagesController, but I don't know how to access models in PagesController.
Is there any way to access several, unassociated models on one page?
Upvotes: 3
Views: 817
Reputation: 4604
I was going to create a Page for PagesController, but I don't know how to access models in PagesController.
With the built-in PagesController, you can't. You'll have to create your own PagesController, which would look something like this pastebin.
Another way to create such a portal page would be to create a Page for display via the built-in PagesController, the view for which would comprise a variety of view elements, each using requestAction
to retrieve their respective data. This can be a tricky approach if you don't or can't employ caching, because requestAction
is not very performant, as it begins a new dispatch cycle every time it's called. However, in conjunction with good, aggressive caching, this is a very modular approach, and very Cake-y, since it encapsulates each element of your dashboard's functionality in its own MVC element.
Edit: just to be extra-clear, if you cannot cache the dashboard's elements well, you want to avoid the requestAction
route. It's just horrifically slow, and it's better to use an approach such as that in balcer's link, though it is perhaps not as elegant.
Upvotes: 1