我有一个用 cakephp 2 开发的网站,我希望它进入我的 default.ctp 有一个菜单,其中包含从数据库中获取的一些元素。如何更改必须使用的控制器的元素?我必须把我的查询放在哪里?因为如果我进入一个模型很容易但是进入default.ctp?我怎样才能做到这一点?这是我的 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>