ブーストラップを統合しようとしていますが、よくわからないことに直面しています... PHP。基本的に必要なのは、class="nav" を ul に追加し、class="dropdown-menu" をサブメニュー ul に追加することですが、nav クラスを 2 回繰り返しています。これがコードです。助けてくれてどうもありがとう!
<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;
}