私はcakephp2で開発されたサイトを持っていて、それを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>