Generally, it's bad practice for a View to perform direct finds against a Model. Even when the model is related to a view via convention, it is usually the controller that has performed the find, and executed a $this->set(compact('modelData')) or similar to expose the model data to a view.
-- With that in mind, you can expose any model to the view via the controller, by finding the data in the controller, and exposing via $this->set(). You just may need to the unrelated models in the controller via $this->loadModel(), or in the $uses variable of the controller, if it is used often.
In the View or in Elements, you may be able to use $this->requestAction() to call a specific controller action to get data to display in a View or Element, however, this is not something I do, so someone else or the CakePHP Book may have better guidelines on actual usage.
Regards
Reuben Helms
On Monday, 20 January 2014 12:32:05 UTC+10, Sam wrote:
On Monday, 20 January 2014 12:32:05 UTC+10, Sam wrote:
From what I understand from cakephp, a view is associated to a model and can only access the model's data. Is it possible for a View to access another unrelated Model's data? What I mean is whether it is possible for a view to access any database table's data, even if it is unrelated?
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment