I have a site developed in cakephp 2 and I want that into my default.ctp there is a menu with some elements taked from the database. How can I change the elements which controller I have to use? Where I have to put my query? Because if I was into a model is easy but into the default.ctp? How can I do that? Here is my default.ctp:
<body> <div class="content"> <div id="navigation"> <ul> <?php if (!empty($authUser)) { ?> <li><?php echo $this->Html->link('I want to change this', array('controller' => 'ingredients', 'action' => 'index')); ?></li> <li><?php echo $this->Html->link('I want to change this', array('controller' => 'brands', 'action' => 'index')); ?></li> <li><?php echo $this->Html->link('I want to change this', array('controller' => 'manufacturers', 'action' => 'index')); ?></li> <?php // $is_logged from UsersController->beforeFilter echo $this->element ('header_menu_logged'); } else { ?> <li><?php echo $this->Html->link('Competizioni', array('controller' => 'brands', 'action' => 'index')); ?></li> <li><?php echo $this->Html->link('Cerca', array('controller' => 'manufacturers', 'action' => 'index')); ?></li> <?php // $current_model echo $this->element ('header_menu', array('selected' => 'Pippo')); } ?> </ul> </div> <div class="page"> <?php // messaggi di stato per le azioni if (empty($flash_element)) { $flash_element = $this->Session->read('flash_element'); if (empty($flash_element)) { $flash_element = 'default'; } } // echo '>'.$flash_element.'<'; $auth_msg = $this->Session->flash('auth', array ('element' => 'flash_'.$flash_element)); $flash_msg = $this->Session->flash('flash', array ('element' => 'flash_'.$flash_element)); if (!empty($auth_msg)) { echo $auth_msg; } if (!empty($flash_msg)) { echo $flash_msg; } ?> <section><!--class="contents"--> <?php echo $content_for_layout; ?> </section> </div> </div> </body>