将 baseurl 值获取到我的控制器中
的返回值。
Zend_View_Helper_BaseUrl
正在创建一个操作助手,它将需要“我该怎么做?”
Am creating an action helper that will require the return value of the
Zend_View_Helper_BaseUrl
How do I go about that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
$this->view->baseUrl()
应该可以工作。但我建议创建新的操作助手,它基本上是视图助手的副本,但您可以修改以满足您的需要:
$this->view->baseUrl()
should work.But I suggest creating new action helper, which is basically a copy of view helper, but you may modify to suit your needs:
您可以通过以下方式从应用程序中的任何位置获取视图的句柄:
视图有可能尚未初始化,但从 ActionHelper 中获取应该不是问题。您还可以通过以下方式获取 BaseUrl 视图助手使用的 URL:
You can get a handle to the view from anywhere in you app with:
There is a chance that the view won't be initialized yet but from an ActionHelper that shouldn't be a problem. You could also get the URL used by the BaseUrl view helper with:
我现在无法验证,但我相信 Action Helper 将可以通过
$this->getActionController()
访问控制器,该控制器具有public $view
所以:I'm not able to verify right now, but I believe that an Action Helper is going to have access to the controller via
$this->getActionController()
which has apublic $view
so: