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)"/}

 

posted @ 2018-09-14 10:07  学徒阿哲  阅读(225)  评论(0编辑  收藏  举报