【问题标题】:In CakePHP, how do I render an element from a plugin inside my controller?在 CakePHP 中,如何从控制器中的插件渲染元素?
【发布时间】:2016-08-26 11:10:32
【问题描述】:

我正在使用带有多个全局插件的 CakePHP。我想使用应用程序本地的控制器从我的一个插件中呈现一个元素。

APP/Controller/CustomreportController.php里面

$this->render('COPlugin.Elements/reportdates'); 

当我尝试查看页面时,我收到以下错误:

缺少视图错误:CustomreportController::paapprovals() 的视图 没找到。

错误:确认您已创建文件: APP/View/Plugin/COPlugin/Elements/reportdates.ctp

所以你看,它希望我在 APP 本身内部创建一个视图:View/Plugin/COPlugin/Elements,而不是使用我已经拥有的视图:ROOT/plugins/COPlugin/View/Elements/reportdates。 ctp。

如何渲染插件中已经存在的元素?

【问题讨论】:

    标签: cakephp


    【解决方案1】:

    cake 2.0 和 2.1 的语法略有不同。文档概述了this 部分中的差异。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-20
      • 2022-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-23
      相关资源
      最近更新 更多