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:
- 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. - 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:
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:
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?