【问题标题】:CakePHP 3.0 Default Theme for PluginCakePHP 3.0 插件的默认主题
【发布时间】:2015-12-07 01:53:02
【问题描述】:

全部,

我的结构如下:

  • 主要应用
    • 自定义主题插件
    • AppController 和其他控制器的插件

我正在为我的主应用程序使用自定义主题插件,但第二个插件默认使用标准 CakePHP 主题。有什么方法可以在不改变主题本身的插件文件的情况下指定它需要使用什么主题?

提前感谢您的意见。

在阅读下面选定的回复后发现了答案。答案如下我有以下:

class PluginSystemPluginsController extends Controller

必须是:

class PluginSystemPluginsController extends AppController

我插件中的 AppController 也在扩展 Controller,应该是

use App\Controller\AppController as BaseController;
class AppController extends BaseController 

【问题讨论】:

    标签: cakephp cakephp-3.1 cakephp-3.x


    【解决方案1】:

    插件的AppController 扩展了主应用程序的AppController。您可以在主应用程序的AppController 中更改主题。

    public function beforeRender(\Cake\Event\Event $event)
    {
        $this->viewBuilder()->theme('Modern');
    }
    

    【讨论】:

    • 这是我的插件AppController 的链接。我想知道这是否是我的插件中的路由问题,而不是 AppController 的问题,因为我仍然有问题。
    • 这是Routes 的链接,这会导致问题吗?
    • 您的插件AppController 不正确。如果您遇到问题,可以使用bake 创建插件。它也会创建插件的AppControllerbook.cakephp.org/3.0/en/bake/usage.html
    • 是的,我看到了。您引导我找到答案,我在上面编辑了我的答案以显示我所做的更改。再次感谢!
    猜你喜欢
    • 1970-01-01
    • 2015-03-28
    • 2011-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-20
    相关资源
    最近更新 更多