织梦dedecms获得顶级栏目及顶级栏目英文方法 。写法如下:

  1. /** 
    * 获取顶级栏目名 
    * {dede:field name='typeid' function="GetTopTypename(@me)" /} 
    **/  
    function GetTopTypename($id)  
    {  
        global $dsql;  
        $row = $dsql->GetOne("SELECT typename,topid FROM dede_arctype WHERE id= $id");  
        if ($row['topid'] == '0')  
        {  
            return $row['typename'];  
        } else {  
            $row1 = $dsql->GetOne("SELECT typename FROM dede_arctype WHERE id= $row[topid]");  
            return $row1['typename'];  
        }  
    }  
      
      
    /** 
    * 获取顶级栏目英文 
    * {dede:field name='typeid' function="GetTopTypeEnName(@me)" /} 
    **/  
    function GetTopTypeEnName($id)  
    {  
        global $dsql;  
        $row = $dsql->GetOne("SELECT typedir,topid FROM dede_arctype WHERE id= $id");  
        if ($row['topid'] == '0')  
        {  
            $en = $row['typedir'];  
             
        } else {  
            $row1 = $dsql->GetOne("SELECT typedir FROM dede_arctype WHERE id= $row[topid]");  
              
            $en = $row1['typedir'];  
        }  
        $l=split("/", $en);  
        $en=array_pop($l);  
        return strtolower($en);  
    }  

写到 includecommon.func.php 最后

发表评论

后才能评论