Including sidebar in Cake PHP template

253 Views Asked by At

I'm trying to create a sidebar in my template but I'm getting Cake\View\Exception\MissingElementException. I've created sidebar.ctp in /src/View/Element/ directory, and call it like this :

<?= $this->element('sidebar') ?>

How can I fix this ?

1

There are 1 best solutions below

1
ndm On BEST ANSWER

Check the docs a little more closely, template files belong into the Template directory, not the View directory.

See Cookbook > Views > Elements