dongyuan8312 2012-03-31 17:26
浏览 114
已采纳

可以突出显示当前菜单项,但不能将class =添加到样式未加标签的菜单项中

<?php $activesidebar[$currentsidebar]="id=isactive";?>

<div class="span3">
<div class="well sidebar-nav hidden-phone">
<ul class="nav nav-list">                   
    <li class="nav-header" <?php echo $activesidebar[1] ?>>Marketing Services</li>
    <li><a href="#">Marketing Technology</a></li>
    <li><a href="#">Generate More Sales</a></li>
    <li><a href="#">Direct Email Marketing</a></li>

    <li class="nav-header" <?php echo $activesidebar[2] ?>>Advertising Services</li>
    <li><a href="../services-advertising-mass-media-network.php">Traditional Medias</a></li>
    <li><a href="#">Online & Social Medias</a></li>
    <li><a href="#">Media Planing & Purchasing</a></li>

    <li class="nav-header" <?php echo $activesidebar[3] ?>>Technology Services</li>
    <li><a href="#">Managed Websites</a></li>
    <li><a href="#">Managed Web Servers</a></li>
    <li><a href="#">Managed Databases</a></li>

    <li class="nav-header" <?php echo $activesidebar[4] ?>>About Us</li>
    <li><a href="../aboutus-contactus.php">Contact Us</a></li>
</ul>
</div>

This is added to the current page I want to add this on.

<?php $currentsidebar =2; include('module-sidebar-navigation.php');?>

I had programmed this menu individually on each page, but to make my website dynamic I used one file and use php includes to load the file. I can get the menu to highlight on the current page assigning an id="isactive", how can I assign id="notactive" to the other 3 menu items that are not active on that page. Is there an else or elseif I have to include?

  • 写回答

1条回答 默认 最新

  • dttwois6098 2012-03-31 17:30
    关注

    Reset the array before setting your preferred index.

    for ($i = 0; $i < 4; $i++) {
         $activesidebar[$i] = "class=\"noactive\"";
    }
    

    Notes:

    • PHP array indices start from 0, not 1.
    • ID's are meant to be unique (ie, there cannot be 2 of the same ID). Use a classname instade.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面