另一个,什么可能是一个愚蠢的问题。我的客户网站上有一个非常深入的导航菜单。我不介意现在更改所有页面和指向 .php 的链接进行艰苦的工作 - 将来会节省很多时间。我想用它<?php include_once("nav.php"); ?>
来把它拉到每一页。目前,活动的父项将根据正在查看的子页面突出显示。菜单结构目前只是每个 .html 页面的一部分。
HTML 标记:
<div id="navigation-wrapper">
<nav id="main-navigation">
<ul class="main-menu">
<li><a href="index.html" title="Home" class="active-page"><span aria-hidden="true" class="li_display nav_icon"></span>About</a>
<ul>
<li><a href="about.html">Corporate Profile</a></li>
<li><a href="about.html#bod">Board of Directors</a></li>
<li><a href="divisions.html">Operating Divisions</a></li>
<li><a href="organisation.html">Organisational Chart</a></li>
<li><a href="corporate-downloads.html">Corporate Documentation</a></li>
</ul>
</li>
<li><a href="#"><span aria-hidden="true" class="li_news nav_icon"></span>Investor</a>
<ul>
<li><a href="investor-overview.html">Overview</a></li>
<li><a href="investor-financial.html">Financial</a></li>
<li><a href="investor-news.html">News</a></li>
<li><a href="investor-events.html">Events</a></li>
<li><a href="investor-general.html">General</a></li>
<li><a href="http://alertscentral.com/" target="_blank">Register for Alerts</a></li>
</ul>
</li>
<li><a href="#"><span aria-hidden="true" class="li_bulb nav_icon"></span>Products</a>
<ul>
<li><a href="mecer.html">Mecer</a></li>
<li><a href="#">Hardware </a>
<ul>
<li><a href="http://www.apc.com/site/apc/index.cfm" target="_blank">APC</a></li>
<li><a href="acer.html">Acer</a></li>
<li><a href="asus.html">ASUS</a></li>
<li><a href="http://www.e-beam.com/home.html" target="_blank">E-Beam</a></li>
<li><a href="fujitsu.html">Fujitsu</a></li>
<li><a href="huawei.html">Huawei</a></li>
<li><a href="lenovo.html">Lenovo</a></li>
<li><a href="microsoft.html">Microsoft</a></li>
<li><a href="nec.html">NEC</a></li>
<li><a href="samsung.html">Samsung</a></li>
<li><a href="toshiba.html">Toshiba</a></li>
</ul>
</li>`enter code here`
<li><a href="#">Mustek Energy</a>
<ul>
<li><a href="panels.html">Solar Panels</a></li>
<li><a href="led.html">LED Lighting Solutions</a></li>
</ul>
</li>
<li><a href="#">Mustek Solutions</a>
<ul>
<li><a href="cloud.html">Mustek Cloud Computing</a></li>
<li><a href="mustek.html#branding">Mustek Digital Signage</a></li>
<li><a href="mustek.html#pos">Mustek POS Solutions</a></li>
<li><a href="mustek.html#security">Mustek Security Technology</a></li>
</ul>
</li>
<li><a href="#">Networking Solutions</a>
<ul>
<li><a href="dlink.html">D-Link</a></li>
<li><a href="huawei.html">Huawei</a></li>
<li><a href="miniflex.html">Miniflex</a></li>
<li><a href="nec.html">NEC</a></li>
<li><a href="n-computing.html">NComputing</a></li>
</ul>
</li>
<li><a href="#">Printing Solutions</a>
<ul>
<li><a href="brother.html">Brother</a></li>
<li><a href="epson.html">Epson</a></li>
</ul>
</li>
<li><a href="http://dealer.mustek.co.za/catalogue.html" target="_blank">Complete Product Catalogue</a></li>
</ul>
</li>
<li><a href="http://dealer.mustek.co.za/contact-us.html" target="_blank"><span aria-hidden="true" class="li_settings nav_icon"></span>Support</a>
<ul>
<li><a href="http://dealer.mustek.co.za/" target="_blank">DealerNet</a></li>
<li><a href="dealer-application.html">Dealer Application Form</a></li>
<li><a href="dealer-locator.html">Dealer Locator</a></li>
<li><a href="http://downloadcenter.mustek.co.za/list.php?dir=Repository" target=_blank>Download Latest Drivers</a></li>
<li><a href="eyespy.html">Mecer EyeSPY</a></li>
</ul>
</li>
<li><a href="#"><span aria-hidden="true" class="li_phone nav_icon"></span>Contact</a>
<ul>
<li><a href="contact.html">Branches</a></li>
<li><a href="mailto:customerliason@mustek.co.za?Subject=General%20Query%20From%20Mustek%20Website">Customer Liaison</a></li>
<li><a href="mailto:ltd@mustek.co.za?Subject=Investor%20Query%20From%20Mustek%20Website">Investors</a></li>
<li><a href="mailto:sales@mustek.co.za?Subject=Sales%20Query%20From%20Mustek%20Website">Sales Queries</a></li>
<li><a href="mailto:helpdesk@mustek.co.za?Subject=Query%20For%20Mustek%20Helpdesk">Technical Queries</a></li>
<li><a href="http://www.pnet.co.za/#s=view_recr_jobs&g=6196" target="_blank">Careers</a></li>
</ul>
</li>
</ul>
</nav>
</div>
如您所见,class="active-page"
指示要显示哪个父图标。我在某处读到,通过添加<?php $page = "page-name"; ?>
它会说出这是哪个页面,并且会像class="active-page"
. 我是否需要在 nav.php 文件中为要引用的页面创建一个 id?
抱歉,我对 PHP 的了解非常有限,但我正在努力学习基础知识。任何帮助是极大的赞赏!