cakephp 从助手中访问视图属性/变量
访问视图属性“passedArgs”(或任何类似的属性)
/* view */
$this->passedArgs
有没有一种合理的方法可以从助手中
?我很乐意自定义帮助程序的 _construct() 或自定义 app_helper...但我不想在每次调用时都将 $this->passedArgs
传递到帮助程序中查看或使用。
is there a reasonable way to access the view attribute "passedArgs" (or any similar)
/* view */
$this->passedArgs
from within a Helper?
I'd be happy to customize the _construct() of the helper or to customize the app_helper... but I don't want to have to pass $this->passedArgs
into the helper on every view or usage.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Cake 2.x 和 3.x
您可以在
_View
对象中查找变量:Cake 1.x
如果您抓取当前视图从帮助程序中获取对象,您应该能够获取其 passArgs。
Cake 1.2.x
如果您从助手中获取当前视图对象,您应该能够获取其 viewVars。
享受,
缺口
Cake 2.x and 3.x
You can look up your variables in the
_View
object:Cake 1.x
If you grab the current view object from within the helper you should be able to get to its passedArgs.
Cake 1.2.x
If you grab the current view object from within the helper you should be able to get to its viewVars.
Enjoy,
Nick
蛋糕3:
Cake 3:
您是否尝试过仅从 AppController 设置视图的值?
Have you tried just setting the view's value from the AppController?