1
votes

I use CakePHP 2.4.1 and after installing CakeDC comments plugin, I got the following Notice:

Notice (1024): Element Not Found: Elements\comments\flat\main.ctp [CORE\Cake\View\View.php, line 415]

My base application is using theme. I initialize theming from the AppController beforeFilter callback as follows:

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. However, this solution does not work.
  2. Copying the \Plugin\Comments\View\Elements\comments directory to \app\View\Themed\Slate\Elements. This solution is working fine. This solution works also if I copied to \app\View\Elements.

I initialze the plugin from app/Config/bootstrap.php as follows:

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: enter image description here

In addition when I try to access http://mywebsite.com/comments it returns error about 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:

enter image description here

In the CakePHP manual there is no any mention about copying view files of a plugin. 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?

1

1 Answers

1
votes

If know well, you can create themed views for cakephp plugins. so after you copied this plugin into Plugins directory crate in your theme in your theme dir. Copy the content of plugin's View directory into: \app\View\Themed\Slate\Plugin\Comments

Cake php will use this directory for your plugin. Like this example \app\View\Themed\Slate\Plugin\Comments\Elements\comments\flat.ctp