我有一個PHP包含我的導航。我想確保顯示當前菜單鏈接,所以我有一個類current-menu-item
。所有作品除了鏈接下拉精...PHP包含,下拉導航選擇問題
每個頁面都有一個<?php $current_page = "pageName"; ?>
,我有<li class="<?php if($current_page == 'dev' || 'seo' || 'mobile' || 'social' || 'hosting') echo "current-menu-item";?>">
在主<li>
作爲選擇,當你在任何一個子的,將顯示鏈接...但是當我嘗試這種方式,它顯示爲在我的網站上的每一頁上選擇...
我的網站是thwebco.com,如果你需要一個參考。
這裏是代碼...
<ul id="nav" class="sf-menu">
<li class="<?php if($current_page == 'home') echo "current-menu-item";?>"><a href="index.php">Home<span class="subheader">Welcome</span></a></li>
<li class="<?php if($current_page == 'development' || 'seo' || 'mobile' || 'social' || 'hosting') echo "current-menu-item";?>"><a href="#">Services<span class="subheader">What we offer</span></a>
<ul>
<li><a href="development.php"><span> Web Design & Development</span></a></li>
<li><a href="seo.php"><span> Search Engine Optimization </span></a></li>
<li><a href="mobile.php"><span> Mobile </span></a></li>
<li><a href="social.php"><span> Social Media </span></a></li>
<li><a href="hosting.php"><span> Web Hosting & Email </span></a></li>
</ul>
</li>
<li><a href="#">Our Work <span class="subheader">See our work</span></a>
<ul>
<li class="<?php if($current_page == 'portfolio') echo "current-menu-item";?>"><a href="portfolio.php"><span>Portfolio </span></a></li>
<li class="<?php if($current_page == 'case') echo "current-menu-item";?>"><a href="case.php"><span>Case Studies </span></a></li>
</ul>
</li>
<li class="<?php if($current_page == 'about') echo "current-menu-item";?>"><a href="about.php">About Us<span class="subheader">Who we are</span></a>
</li>
<li class="<?php if($current_page == 'contact') echo "current-menu-item";?>"><a href="contact.php">Contact<span class="subheader">Get in touch</span></a></li>
<li class="<?php if($current_page == 'quote') echo "current-menu-item";?>"><a href="quote.php">Get A Quote<span class="subheader">Let us help</span></a></li>
</ul>