I have just started a project with cakePHP 2.0. I am using an element to render a sidebar menu. I would like to specify the css and JS files for the menu in the menu element and not add them in my head tag (in case I'd like to conditionally render different sidebars). For some reason my scripts and CSS are not being output.. any ideas why?
Layouts/Default.ctp
<head>
<?php
echo $this->fetch('css');
echo $this->fetch('script');
?>
</head>
....
<div id="leftcolumn">
<?php echo $this->element('sidebar/menu'); ?>
</div>
Elements/sidebar/menu.ctp
$this->Html->script('menu', array('inline' => false));
$this->Html->css('menu', null, array('inline' => false));
<div class="sidebarmenu"><ul><li>Menu Item</li></ul></div>
CSS and javascript are in webroot/css/menu.css and webroot/js/menu.js respectively.
If I put the Html->script and Html->css declarations in a view file or home.ctp or default.ctp they get added to the css and script blocks and are output just fine. When they are declared in the element file menu.ctp they don't work. Is there something I'm missing?