I would like to get some input regarding the feasibility of the following scenario/design pattern:
I would like to insert a View
from a Category Plugin (/category/categories/tree
) into one of my application Views (/posts/edit/3
) as if it is an CakePHP element.
The inserted View
has a high level of functionality (sorting, adding, deleting, etc...) and therefore simply calling echo $this->element();
does not seem appropriate to me. That 'feels' more like a practice appropriate in situations where 'snippet'/lower level functionality is needed.
My question: is this possible in CakePHP, if so: how to do this? (just a rough outline of the way to go would suffice)
My first idea is to call an element
from the plugin and use $this->requestAction();
from the element.
But as I said earlier is my association with elements one of little functionality/snippet. Using a controller method and its View
'feels' more appropriate. But I don't know how to 'call' a View within a View.
Main reason why I would want this:
full Controller functionality.
- activate helpers based on Plugin requirements (this should be of no concern to the posts-controller)
- beforeFilter and beforeRender of Plugin might be of use. For example:
$this->set('modelName', $this->modelClass);