Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
缺少以CakePHP为主题的应用程序和插件视图元素_Php_Cakephp_Plugins_Cakedc_Cakephp 2.4 - Fatal编程技术网

缺少以CakePHP为主题的应用程序和插件视图元素

缺少以CakePHP为主题的应用程序和插件视图元素,php,cakephp,plugins,cakedc,cakephp-2.4,Php,Cakephp,Plugins,Cakedc,Cakephp 2.4,我使用CakePHP 2.4.1,在安装CakeDC评论插件后,我收到以下通知: 注意(1024):找不到元素:Elements\comments\flat\main.ctp [CORE\Cake\View\View.php,第415行] 我的基础应用程序使用主题。我从AppController beforeFilter回调中初始化主题,如下所示: class AppController extends Controller { function beforeFilter(){

我使用CakePHP 2.4.1,在安装CakeDC评论插件后,我收到以下通知:

注意(1024):找不到元素:Elements\comments\flat\main.ctp [CORE\Cake\View\View.php,第415行]

我的基础应用程序使用主题。我从AppController beforeFilter回调中初始化主题,如下所示:

class AppController extends Controller { 
     function beforeFilter(){
     App::uses('Security', 'Utility');
     $this->theme = 'Slate';  
     $this->layout = 'blog' ;
     } 
}
CakePlugin::loadAll();
为了解决这个问题,我尝试了两种方法,其中一种成功了,但另一种没有如下所示:

class AppController extends Controller { 
     function beforeFilter(){
     App::uses('Security', 'Utility');
     $this->theme = 'Slate';  
     $this->layout = 'blog' ;
     } 
}
CakePlugin::loadAll();
  • 创建
    \Plugin\Comments\View\Themed\Slate\Elements
    ,然后将
    \Plugin\Comments\View\Elements
    的所有内容复制到新目录。但是,此解决方案不起作用
  • \Plugin\Comments\View\Elements\Comments
    目录复制到
    \app\View\moted\Slate\Elements
    。这个解决方案很有效。如果我复制到
    \app\View\Elements
    ,此解决方案也可以使用
  • 我从app/Config/bootstrap.php初始化插件,如下所示:

    class AppController extends Controller { 
         function beforeFilter(){
         App::uses('Security', 'Utility');
         $this->theme = 'Slate';  
         $this->layout = 'blog' ;
         } 
    }
    
    CakePlugin::loadAll();
    
    并从控制器发送,如下所示:

    public function callback_commentsInitType() {
    
            return 'flat'; // threaded, tree and flat supported
        }
    
    以下是通知的屏幕截图:

    此外,当我尝试访问
    http://mywebsite.com/comments
    它返回关于
    操作注释的错误找不到controller::index()。
    在missy布局中呈现,该布局混合了我的主题布局和默认CakePHP布局,下面的快照演示了它:


    在CakePHP手册中没有提到复制插件的视图文件。它应该能正常工作!我不知道为什么插件没有找到它的元素?!我怎样才能使这个插件与应用程序的主题视图正确交互?

    如果你知道得很清楚,你可以为cakephp插件创建主题视图。所以,在你把这个插件复制到插件目录之后,你的主题目录中的主题板条箱。 将插件视图目录的内容复制到: \app\View\Themed\Slate\Plugin\Comments

    Cake php将为您的插件使用此目录。
    像这个例子一样\app\View\Themed\Slate\Plugin\Comments\Elements\Comments\flat.ctp

    如果你知道的很清楚,你可以为cakephp插件创建主题视图。所以,在你把这个插件复制到插件目录之后,你的主题目录中的主题板条箱。 将插件视图目录的内容复制到: \app\View\Themed\Slate\Plugin\Comments

    Cake php将为您的插件使用此目录。
    像这个例子一样\app\View\Themed\Slate\Plugin\Comments\Elements\Comments\flat.ctp

    谢谢这是有用的提示。谢谢这是有用的提示。