zoukankan      html  css  js  c++  java
  • HDCMS导航高亮显示!解决办法

    第一种方法:(传递class)

    <channel type='top' row='8' class='cur' >
        <li class='{$field.class}'>
           <h3><a href='' class="{$field.caturl}">{$field.catname}</a></h3>
        </li>
    </channel>

    第二种方法:写公共函数 functions.php

    hd / Common / Functions / functions.php

    //分类列表获得PID
    function allList($pid = 0){
      if($pid == 0){
        return false;
      }
      $category = M('category')->where(array('cid'=>$pid))->field('cid,pid')->find();  
      $cate = $category['pid'] ? allList($category['pid']):$category['cid'];
      return $cate;
    }

    循环遍历:

    <channel type='top' row='8'>
        <li class="<?php if($field['cid'] == allList($_GET['cid'])): ?><?php echo 'dlHover' ?><?php endif; ?>">
           <h3><a href='' class="{$field.caturl}">{$field.catname}</a></h3>
        </li>
    </channel>

    使用下来,第二种方法更灵活,适用于二级分类和三级分类;

  • 相关阅读:
    第二章例2-11
    第二章例2-10
    例2-11
    例2-9+2-10
    例2-7+例2-8
    例2-5+2-6
    例2-4
    例2-3
    例2-2
    例2-1
  • 原文地址:https://www.cnblogs.com/e0yu/p/7244119.html
Copyright © 2011-2022 走看看