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

这里的技术是共享的

DEDECMS列表页调用当前栏目父级栏目的方法

本文实例讲述了DEDECMS列表页调用当前栏目父级栏目的方法。分享给大家供大家参考。具体实现方法如下:

修改方法如下

首先找到如下代码:
 

复制代码
代码如下:
if($type=='top') 

$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath 
From `dede_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 `dede_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 `dede_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line "; 
}

然后将下面代码拷贝到其后面:

复制代码
代码如下:
else if($type=='topone') 

if($reid==0) return ''; 
$rowR = $dsql->GetOne("SELECT * FROM `dede_arctype` WHERE id='$typeid' "); 
$topids = $rowR['topid']; 
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath 
FROM `dede_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 `dede_arctype` WHERE id='$typeid' "); 
$reid = $rowR['reid']; 
$rowR = $dsql->GetOne("SELECT * FROM `dede_arctype` WHERE id='$reid' "); 
$reid = $rowR['reid']; 
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath 
FROM `dede_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line "; 
}

说明topone是调用当前目录对应的顶级目录'fatherlist' 是调用上一级目录,当前目录对应的顶级目录标记:
复制代码
代码如下:
{dede:channel type='topone'}[field:typename/]{/dede:channel}

 

这个方法绝对可以,如果想用链接的话,就要[field:typeurl].

希望本文所述对大家的dedecms建站有所帮助。

来自 http://www.jb51.net/cms/246897.html
 

本文实例讲述了DEDECMS列表页调用当前栏目父级栏目的方法。分享给大家供大家参考。具体实现方法如下:

修改方法如下

首先找到如下代码:

复制代码代码如下:if($type=='top')

{

$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath

From `dede_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 `dede_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 `dede_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";

}

然后将下面代码拷贝到其后面:

复制代码代码如下:else if($type=='topone')

{

if($reid==0) return '';

$rowR = $dsql->GetOne("SELECT * FROM `dede_arctype` WHERE id='$typeid' ");

$topids = $rowR['topid'];

$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath

FROM `dede_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 `dede_arctype` WHERE id='$typeid' ");

$reid = $rowR['reid'];

$rowR = $dsql->GetOne("SELECT * FROM `dede_arctype` WHERE id='$reid' ");

$reid = $rowR['reid'];

$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath

FROM `dede_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";

}

说明topone是调用当前目录对应的顶级目录'fatherlist' 是调用上一级目录,当前目录对应的顶级目录标记:

复制代码代码如下:{dede:channel type='topone'}[field:typename/]{/dede:channel}

这个方法绝对可以,如果想用链接的话,就要[field:typeurl].

来自 http://www.bubuko.com/infodetail-836250.html

唯物品评历史

关注"唯物品评历史",跟着泪痕春雨先生,读懂历史,看彻人生

打开隐藏二维码