在织梦中上一级调用下一级子栏目调用常用到,但是在调用子栏目调用父级列表 更甚者调用父级的父级列表织梦的官方模板是没有提供的,在这里我给大家一个简单的方法
修改/include/taglib/channel.lib.php 文件
修改方法如下首先找到如下代码
if($type=='top')
{
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
From `#@__arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line ";
}
else if($type=='son')
{
if($typeid==0) return '';
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
From `#@__arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line ";
}
else if($type=='self')
{
if($reid==0) return '';
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
}
然后将下面代码拷贝到其后面
else if($type=='topone')/*调用顶级栏目 在where后面的条件中去除 And id='$topids' 将调用整顶级列表*/
{
if($reid==0) return '';
$rowR = $dsql->GetOne("SELECT * FROM `#@__arctype` WHERE id='$typeid' ");
$topids = $rowR['topid'];
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
FROM `#@__arctype` WHERE reid='0' And id='$topids' And ishidden<>1 order by sortrank asc limit 0, $line ";
}
else if($type=='fatherlist')
/*调用上一级列表 如果将 $rowR = $dsql->GetOne("SELECT * FROM `#@__arctype` WHERE id='$typeid' ");
$reid = $rowR['reid']; 在写一次将调用上一级的上一级目录列表*/
{
$rowR = $dsql->GetOne("SELECT * FROM `#@__arctype` WHERE id='$typeid' ");
$reid = $rowR['reid'];
$rowR = $dsql->GetOne("SELECT * FROM `#@__arctype` WHERE id='$reid' ");
$reid = $rowR['reid'];
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
}
说明topone是调用当前目录对应的顶级目录 'fatherlist' 是调用上一级目录