简体   繁体   English

CakePHP主题应用程序和插件视图元素丢失

[英]CakePHP Themed application and plugin view elements missing

I use CakePHP 2.4.1 and after installing CakeDC comments plugin, I got the following Notice: 我使用CakePHP 2.4.1,并在安装CakeDC注释插件后收到以下通知:

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

My base application is using theme. 我的基本应用程序正在使用主题。 I initialize theming from the AppController beforeFilter callback as follows: 我从AppController beforeFilter回调中初始化主题,如下所示:

class AppController extends Controller { 
     function beforeFilter(){
     App::uses('Security', 'Utility');
     $this->theme = 'Slate';  
     $this->layout = 'blog' ;
     } 
}

To solve this issue I tried two methods, one of them succeeded but the other is not as follows: 为了解决此问题,我尝试了两种方法,其中一种成功,但另一种不是如下所示:

  1. Creating \\Plugin\\Comments\\View\\Themed\\Slate\\Elements and then copying all the contents of \\Plugin\\Comments\\View\\Elements to the new directory. 创建\\Plugin\\Comments\\View\\Themed\\Slate\\Elements ,然后将\\Plugin\\Comments\\View\\Elements所有内容复制到新目录。 However, this solution does not work . 但是,此解决方案不起作用
  2. Copying the \\Plugin\\Comments\\View\\Elements\\comments directory to \\app\\View\\Themed\\Slate\\Elements . \\Plugin\\Comments\\View\\Elements\\comments目录复制到\\app\\View\\Themed\\Slate\\Elements This solution is working fine. 该解决方案工作正常。 This solution works also if I copied to \\app\\View\\Elements . 如果我复制到\\app\\View\\Elements此解决方案也可以使用。

I initialze the plugin from app/Config/bootstrap.php as follows: 我从app / Config / bootstrap.php初始化插件,如下所示:

CakePlugin::loadAll();

And from the controller as: 并从控制器为:

public function callback_commentsInitType() {

        return 'flat'; // threaded, tree and flat supported
    }

The following is a screen shot of the notice: 以下是通知的屏幕截图: 在此处输入图片说明

In addition when I try to access http://mywebsite.com/comments it returns error about Action CommentsController::index() could not be found. 另外,当我尝试访问http://mywebsite.com/comments它返回有关Action CommentsController::index() could not be found.错误Action CommentsController::index() could not be found. which is rendered in missy layout that mix my themed layout and the default CakePHP layout, the following shot demonstrates it: 它以混合了我主题的布局和默认的CakePHP布局的missy布局呈现,下面的快照演示了它:

在此处输入图片说明

In the CakePHP manual there is no any mention about copying view files of a plugin. 在CakePHP手册中,没有提及复制插件的视图文件。 It should work as it is! 它应该可以正常工作! I don't know why the plugin missed its way to its elements?! 我不知道为什么插件错过了它的元素? How could I make this plugin interaction correctly with the theme view of the app? 如何使该插件与应用程序的主题视图正确交互?

If know well, you can create themed views for cakephp plugins. 如果知道的话,您可以为cakephp插件创建主题视图。 so after you copied this plugin into Plugins directory crate in your theme in your theme dir. 因此,在将此插件复制到Plugins目录后,请在主题目录中的主题中创建箱子。 Copy the content of plugin's View directory into: \\app\\View\\Themed\\Slate\\Plugin\\Comments 将插件的View目录的内容复制到:\\ app \\ View \\ Themed \\ Slate \\ Plugin \\ Comments

Cake php will use this directory for your plugin. Cake php将使用此目录作为您的插件。 Like this example \\app\\View\\Themed\\Slate\\Plugin\\Comments\\Elements\\comments\\flat.ctp 像这个例子\\ app \\ View \\ Themed \\ Slate \\ Plugin \\ Comments \\ Elements \\ comments \\ flat.ctp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM