欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

dedecms 栏目 当前栏目 加上 hover current active 样式 自己亲自做的 有大用 有大大用 有大大大用

shiping1 的头像

记住下面自定义的函数可能不起作用 一定要在  见 本页面的   最后  3) 不太行 最好 4)

1)//在标签中调用下面的函数 
2)下面的这个函数定义在time.helper.php文件中


//根据aid得到tid
function getTidByAid($aid)
{

   global $dsql;
   $tid = 0;
   if(!empty($aid)){  //这是获取普通文章
       $row = $dsql->getOne("select typeid from `#@__archives` where id='$aid'");
       $tid = $row['typeid'];
   }

   return $tid;
}



//根据tid来决定采用hover的样式
function getHover($oldTid)
{
    global $tid,$aid;
    if(empty($tid) && !empty($aid)){
        $tid = getTidByAid($aid);
    }
    
    $topId=GetTopid($tid);
    
    
    $allIdsIncludeSon = GetSonIds($topId,0);
    
    if($topId == $oldTid || $tid==$oldTid){
        return "class='hover'";
    }
    else {
        return '';
    }
    
}


//最好用这个代码吧 不用上面的getHover函数 根据tid来决定采用hover的样式
function getHoverByTid($oldTid)
{
   global $tid;
   global $aid;
   global $id;

   if($tid==$oldTid){
       return "current";
   }
   if(empty($tid) && (!empty($aid)||!empty($id))){
       empty($aid) && $aid=$id;
       $tid = getTidByAid($aid); //这是取专题页面的 typeid
       if($tid==$oldTid){
           return "current";
       }
   }

   return '';

}



3)发现到 直接动态 hover起作用 但是 生成静态它不起作用
修改 dede\makehtml_archives_action.php  109左右的一句
while($row=$dsql->GetObject('out'))
{
    $tjnum++;
    $id = $row->id;
    $aid=$id;//就加上这一句
    $ac = new Archives($id);
    $rurl = $ac->MakeHtml($isremote);
}


 3)好像不太行, 最好用 4)

4)   include\arc.archives.class.php

约 701 行 

增加下面的红色的行

  function MakeHtml($isremote=0)

    {


      global $aid;

      $aid = $this->ArcID;

      global $tid;

      $tid = $this->TypeLink->TypeID;


        global $cfg_remote_site,$fileFirst;

        if($this->IsError)

        {


普通分类: