我想在CakePHP中创建一个呈现我的菜单(Bootstrap)的Elemnt。
My Database 我的元素:
<?php
if (! isset ( $menus ) || empty ( $menus )) :
$menus = $this->requestAction('/menus/index');
endif;
foreach ( $menus as $menu ){
if($menu['Menu']['parent'] == 0){
?>
<li>
<?php
$inside = "<i class='".$menu['Menu']['icon']."'></i><span>".$menu['Menu']['name']."</span></a>";
echo $this->Html->link( $inside, array('controller' => $menu['Menu']['controller'],'action' => $menu['Menu']['action']), array( 'escape'=>false)); ?>
</li>
<?php } }
?>
我如何呈现它:
<?php echo $this->element('Menus/main'); ?>
下拉列表的示例:
<li class="dropdown">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
<i class="icon-long-arrow-down"></i>
<span>Drops</span>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="icons.html">Icons</a></li>
<li><a href="faq.html">FAQ</a></li>
<li><a href="pricing.html">Pricing Plans</a></li>
<li><a href="login.html">Login</a></li>
<li><a href="signup.html">Signup</a></li>
<li><a href="error.html">404</a></li>
</ul>
</li>
我试图在View中渲染它,但问题是我不能在示例中调用Controller的函数来询问是否有Entrie Childs。 一些想法如何使用CakePHP正确渲染菜单?