Zend Framework Widget 教程问题
我尝试遵循本教程,但无法使其工作:
我按照描述做了一切,但我不知道如何使其在我的控制器中可用。我的文件系统如下所示:
- application
- controllers
- IndexController.php
- modules
- user
- configs
user.ini
- controllers
- forms
Login.php
- helpers
HandleLogin.php
- views
- scripts
login.phmtl
profile.phtml
Bootstrap.php
- views
How do I use the HandleLogin Helper in my IndexController?我真的不知道,我正在尝试一天多的时间,我几乎想把我的电脑扔出窗外;)。因此,任何帮助将不胜感激!
I try to follow this tutorial, but I can't get it to work:
I did everything as described, but I don't know how to make it available in my controllers. My filesystem looks like this:
- application
- controllers
- IndexController.php
- modules
- user
- configs
user.ini
- controllers
- forms
Login.php
- helpers
HandleLogin.php
- views
- scripts
login.phmtl
profile.phtml
Bootstrap.php
- views
How do I use the HandleLogin Helper in my IndexController? I really have no idea and I'm looking an trying for more then a day and I almost want to throw my PC out of the window ;). So any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来小部件插件没有在任何地方被调用。
有几件事需要检查:
您是否有该模块的
Bootstrap.php
文件?这个引导文件有
_initWidgets()
方法吗?该方法是否调用:
$widget = new Module_Widget_Name; // 它可以调用吗?
Zend_Controller_Action_HelperBroker::addHelper($widget);
你注册了widget资源了吗?
公共函数_initResourceLoader()
<代码>{
$loader = $this->getResourceLoader();
$loader->addResourceType('helper', 'helpers', 'Helper');
$loader->addResourceType('widget', 'widgets', 'Widget');
<代码>}
application.ini 是否包含
resources.modules[] =
行?Looks like the widget plugin is not called anywhere.
Few things to check:
Do you have a
Bootstrap.php
file for the module?Does this bootstrap file has
_initWidgets()
method?Does this method call:
$widget = new Module_Widget_Name; // is it callable?
Zend_Controller_Action_HelperBroker::addHelper($widget);
Have you registered widget resource?
public function _initResourceLoader()
{
$loader = $this->getResourceLoader();
$loader->addResourceType('helper', 'helpers', 'Helper');
$loader->addResourceType('widget', 'widgets', 'Widget');
}
Does
application.ini
containsresources.modules[] =
line?你不知道。本教程的重点是创建一个独立于任何特定控制器运行的可重用小部件。当应用程序收到请求时,它将运行其调度周期并自动触发 preDispatch 上的操作助手:
助手将获取当前控制器(无论哪个可能适用于该请求)以获取 View 实例并使用表单对其进行配置
You dont. The point of the tutorial is to create a reusable widget that runs independent from any specific controllers. When the application receives a request, it will run through it's dispatch cycle and trigger the action helper on preDispatch automatically:
The helper will fetch the current controller (whichever that may be for that request) to get the View instance and configure it with the form