DEDEcms调用当前栏目顶级栏目url地址

include/common.func.php 找到这个文件

在文件最下方加入以下代码:

//获取顶级栏目url 
function GetTopTypeurl($id)
{
    global $dsql;
    $row = $dsql->GetOne("SELECT sitepath,topid FROM think_arctype WHERE id= $id");
    if ($row['topid'] == '0')
    {
        $url = str_replace('{cmspath}','',$row['sitepath']);
        return $url;
    }
    else
    {
        $row1 = $dsql->GetOne("SELECT sitepath FROM think_arctype WHERE id= $row[topid]");
        $url1 = str_replace('{cmspath}','',$row1['sitepath']);
        return $url1;
    }
} 

调用方法为:{dede:field.typeid function="GetTopTypeurl(@me)"/}

原文地址:https://www.cnblogs.com/testzhe/p/9644886.html