1、在include\taglib建立randomartList.lib.PHP
内容如下:
if(!defined('DEDEINC')) exit('Request Error!');
function lib_randomartList(&$ctag, &$refObj)
{
global $dsql;
//属性处理
//topID 指定顶级树 ID ,指定后,前一个属性将无效
$attList="typeID|0,showall|,currentstyle|,cacheID|";
FillAttsDefault($ctag->CAttribute->Items,$attList);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$revalue = '';
//读取固定的缓存块
$cacheID = trim($cacheID);
if($cacheID !='') {
$revalue = GetCacheBlock($cacheID);
if($revalue != '') return $revalue;
}
//如果属性里没指定栏目ID,从引用类里获取栏目信息
if(empty($typeID))
{
if( isset($refObj->Typelink->TypeInfos['ID']) )
{
$typeID = $refObj->Typelink->TypeInfos['ID'];
$reID = $refObj->Typelink->TypeInfos['reID'];
$topID = $refObj->Typelink->TypeInfos['topID'];
}
else {
$typeID = 0;
}
}
else
{
$row2 = $dsql->Getone("SELECT reID,topID,channeltype,ispart FROM `dede_arctype` WHERE reID='$topID' ");
if(!is_array($row2))
{
$typeID = $reID = $topID = $channeltype = $ispart = 0;
} else {
$reID = $row2['reID'];
$channeltype = $row2['channeltype'];
$ispart = $row2['ispart'];
$typepID = $row2['ID'];
}
}
//调用TypeID
if( !empty($topID) )
{
$topquery = "SELECT ID,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reID='$topID' And ishIDden<>1 order by sortrank asc";
}
$dsql->Execute('t', $topquery);
while($row = $dsql->GetArray('t'))
{
$row['typelink'] = GetoneTypeUrlA($row);
//处理同级栏目中,当前栏目的样式
if( $row['ID']==$typeID && $currentstyle!='' )
{
$linkOkstr = $currentstyle;
$linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);
$linkOkstr = str_replace("~ID~",$row['ID'],$linkOkstr);
$linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);
$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
$revalue .= $linkOkstr;
}
else
{
$revalue .= " }
randomartListSon($row['ID'],$typeID,$currentstyle, $revalue);
}
if($cacheID !='') {
WriteCacheBlock($cacheID, $revalue);
}
return $revalue;
}
function randomartListSon($ID,&$revalue)
{
global $dsql;
$query = "SELECT ID,sitepath FROM `dede_arctype` WHERE reID='{$ID}' And ishIDden<>1 order by sortrank asc";
$dsql->Execute($ID, $query);
$thisv = '';
while($row = $dsql->GetArray($ID))
{
$row['typelink'] = GetoneTypeUrlA($row);
//处理同级栏目中,当前栏目的样式
if( $row['ID']==$typeID && $currentstyle!='' )
{
$linkOkstr = $currentstyle;
$linkOkstr = str_replace("~rel~",$linkOkstr);
$thisv .= $linkOkstr;
}
else
{
$thisv .= " }
randomartListSon($row['ID'], $thisv);
}
if($thisv!='') $revalue .= " }
2、调用方式:
{dede:randomartList topID='12' currentadsbygoogle" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4605373693034661" data-ad-slot="1300602012"> 总结
以上是内存溢出为你收集整理的织梦dedecms5.7 无限级多级栏目菜单调用方法全部内容,希望文章能够帮你解决织梦dedecms5.7 无限级多级栏目菜单调用方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)