【问题标题】:Global helper for Zend module-structureZend 模块结构的全局助手
【发布时间】:2011-11-18 09:44:27
【问题描述】:

我的文件如下所示:

/Zend
  /Application
    /Configs
    /Modules
       /home
          /controllers
          /views
       /login
          /controllerS              
          /forms
          /library
             /login
          /models
          /plugins
          /views

我想创建一个可以被所有模块使用的助手。有点像“全球帮手”。有没有标准的方法来做到这一点?

【问题讨论】:

    标签: helper view-helpers zend-framework


    【解决方案1】:

    什么样的帮手?看法?或者类似动作助手之类的东西?如果它只是一个实用样式类(未附加到 MVC 的特定部分),则将其放入 /library/NAMESPACE 效果很好。

    然后将该命名空间添加到application.ini 中的自动加载器。

    autoloadernamespaces[] = NAMESPACE
    

    然后你就可以了

    $helper = new NAMESPACE_Helper();
    

    【讨论】:

    • ` $view = new Zend_View(); $mypath=$this->view->getHelperPaths(); $view->addHelperPath($mypath['Login_View_Helper_'], 'RenderIfExists'); $this->renderIfExists('login.phtml'); `
    • ` $view = new Zend_View(); $mypath=$this->view->getHelperPaths(); $view->addHelperPath($mypath['Login_View_Helper_'][0], 'RenderIfExists'); $this->renderIfExists('login.phtml'); ` 这给了我错误:Message: Method "renderIfExists" does not exist and was not trapped in __call()。我的助手的路径是正确的。我已经用echo $mypath['Login_View_Helper_'][0]检查了它
    猜你喜欢
    • 2011-04-20
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    • 1970-01-01
    • 2011-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多