开发者

There is a way to use a controller action directly as an element in CakePHP?

开发者 https://www.devze.com 2022-12-12 17:38 出处:网络
I want to use the view for one controller action inside another view with CakePHP, and passing some variables. Anybody has been work on this situation or something 开发者_如何学JAVAsimilar?I think I u

I want to use the view for one controller action inside another view with CakePHP, and passing some variables. Anybody has been work on this situation or something 开发者_如何学JAVAsimilar?


I think I understand what you're attempting, but I'm pretty sure it's not directly possible - as you've found.

What I tend to do in this situation is find the amount of code I want to replicate in both views, put it in an element and then call $this->renderElement('path-to/element') inside both views.

You could do something with $this->requestAction('controller/function') but it carries a large overhead.

I would suggest considering reformatting your code and using the element suggestion above.

0

精彩评论

暂无评论...
验证码 换一张
取 消