我正在尝试集成boostrap,但我正面临着我不太了解的事情...... PHP。基本上我需要的是添加 class="nav" 到 ul 和 class="dropdown-menu" 到子菜单 ul 但它重复两次导航类。这是代码。非常感谢你的帮忙!
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<div class="navbar">
<!-- menu start -->
<ul class="nav" id="nav">
<li class="level0"> <a class="dropdown-toggle" href="#" class=""><span>Dashboard</span></a></li>
<li onmouseover="Element.addClassName(this,'over')" onmouseout="Element.removeClassName(this,'over')" class=" active parent dropdown level0"> <a class="dropdown-toggle" href="#" onclick="return false" class="active"><span>Sales</span></a>
<ul class="nav">
<li class="level1"> <a class="dropdown-toggle" href="#" class=""><span>Orders</span></a></li>
<li class="level1"> <a class="dropdown-toggle" href="#" class=""><span>Invoices</span></a></li>
<li class="level1"> <a class="dropdown-toggle" href="#" class=""><span>Shipments</span></a></li>
<li class="level1"> <a class="dropdown-toggle" href="#" class=""><span>Credit Memos</span></a></li>
<li class="level1"> <a class="dropdown-toggle" href="#" class=""><span>Transactions</span></a></li>
<li class="level1"> <a class="dropdown-toggle" href="#" class=""><span>Recurring Profiles (beta)</span></a></li>
<li class="level1"> <a class="dropdown-toggle" href="#" class=""><span>Billing Agreements</span></a></li>
<li class="level1"> <a class="dropdown-toggle" href="#" class=""><span>Terms and conditions</span></a></li>
<li onmouseover="Element.addClassName(this,'over')" onmouseout="Element.removeClassName(this,'over')" class=" parent dropdown last level1"> <a class="dropdown-toggle" href="#" onclick="return false" class=""><span>Tax</span></a>
<ul class="nav"> <!--Need to add .dropdown-menu here-->
<li class="level2"> <a class="dropdown-toggle" href="#" class=""><span>Manage Tax Rules</span></a></li>
<li class="level2"> <a class="dropdown-toggle" href="#" class=""><span>Manage Tax Zones & Rates</span></a></li>
<li class="level2"> <a class="dropdown-toggle" href="#" class=""><span>Import / Export Tax Rates</span></a></li>
<li class="level2"> <a class="dropdown-toggle" href="#" class=""><span>Customer Tax Classes</span></a></li>
<li class="last level2"> <a class="dropdown-toggle" href="#" class=""><span>Product Tax Classes</span></a></li>
</ul>
</li>
</ul>
</li>
<!--THE PHP-->
<?php
public function getMenuLevel($menu, $level = 0)
{
$html = '<ul class="nav" ' . (!$level ? 'id="nav"' : '') . '>' . PHP_EOL;
foreach ($menu as $item) {
$html .= '<li ' . (!empty($item['children']) ? 'onmouseover="Element.addClassName(this,\'over\')" '
. 'onmouseout="Element.removeClassName(this,\'over\')"' : '') . ' class="'
. (!$level && !empty($item['active']) ? ' active' : '') . ' '
. (!empty($item['children']) ? ' parent dropdown' : '')
. (!empty($level) && !empty($item['last']) ? ' last' : '')
. ' level' . $level . '"> <a class="dropdown-toggle" href="' . $item['url'] . '" '
. (!empty($item['title']) ? 'title="' . $item['title'] . '"' : '') . ' '
. (!empty($item['click']) ? 'onclick="' . $item['click'] . '"' : '') . ' class="'
. ($level === 0 && !empty($item['active']) ? 'active' : '') . '"><span>'
. $this->escapeHtml($item['label']) . '</span></a>' . PHP_EOL;
if (!empty($item['children'])) {
$html .= $this->getMenuLevel($item['children'], $level + 1);
}
$html .= '</li>' . PHP_EOL;
}
$html .= '</ul>' . PHP_EOL;
return $html;
}