When using dedecms dedecms, want to call peer in the list of article columns and content pages, of course, may be used {dede: channelartlist typeid = '1' row = '5'} method specified column id, but to automatically determine the current section of the column at the same level would not work or need to assign a template for each top-level topic, this is very troublesome. This article will give a more simple way:
1. Locate the \ include \ taglib \ channelartlist.lib.php file
Find:
$attlist = 'typeid|0,row|20,cacheid|';
change into:
$attlist = 'typeid|0,row|20,cacheid|,type|'; //这边加个 type 实现 在子栏目下调用 同级子栏目的信息
Then look for:
-
if($typeid==0 || $typeid=='top') {
-
$tpsql = " reid=0 AND ispart<>2 AND ishidden<>1 AND channeltype>0 ";
-
}
change into:
-
IF ($ of the type == 'Reid') // call the sub-column content under the parent directory
-
{
-
$reid = $refObj->TypeLink->TypeInfos[ 'reid'];
-
$tpsql = " reid='$reid' AND ispart<>2 AND ishidden<>1 ";
-
}
-
else if($typeid==0 || $typeid=='top') {
-
$tpsql = " reid=0 AND ispart<>2 AND ishidden<>1 AND channeltype>0 ";
-
}
Save the above file. Then in the list page or use the content page:
-
{dede:channelartlist type='reid' row='5'}
-
Underlying loop code
-
{/dede:channelartlist}
It can easily call.