您现在的位置是:首页 > cms教程 > DedeCMS教程DedeCMS教程
织梦标签调用dede栏目大循环加小循环调用的实现方法
醉易2023-10-03DedeCMS教程已有人查阅
导读dede的栏目只能循环一次。所以需要修改;织梦网站建设代码号在5.7中试验了一下可以用。修改文件:\include\taglib目录下的channel.lib.php,请将以下代码全部复制替换上述文件。
dede的栏目只能循环一次。所以需要修改;织梦网站建设代码号在5.7中试验了一下可以用。
修改文件:\include\taglib目录下的channel.lib.php,请将以下代码全部复制替换上述文件。
以下为引用的内容:
这个的作用就是当你的栏目有很多子栏目无限分级的时候方便你取子栏目的
例子
修改文件:\include\taglib目录下的channel.lib.php,请将以下代码全部复制替换上述文件。
以下为引用的内容:
<?php
function lib_channel(&$ctag,&$refObj)
{
global $_sys_globals,$envs,$dsql;
$attlist = "typeid|0,reid|0,row|100,col|1,type|son,currentstyle|";
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$innertext = $ctag->GetInnerText();
$cacheid = trim($cacheid);
if($cacheid !='') {
$likeType = GetCacheBlock($cacheid);
if($likeType != '') return $likeType;
}
$reid = 0;
$topid = 0;
if(empty($typeid) && $envs['typeid']!=0)
{
$typeid = $envs['typeid'];
$reid = $envs['reid'];
}else{
$reid=0;
}
if($type==''||$type=='sun') $type="son";
if($innertext=='') $innertext = GetSysTemplets("channel_list.htm");
if($reid==0 && $typeid>0)
{
$dbrow = $dsql->GetOne("Select reid From dede_arctype where id='$typeid' ");
if(is_array($dbrow)) $reid = $dbrow['reid'];
}
$likeType = '';
if($type=='top')
{
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
From dede_arctype where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row";
}
else if($type=="son")
{
//if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
if($typeid==0) {
return '';
}
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
From dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
}
else if($type=="self")
{
if($reid==0) {
return '';
}
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
From `dede_arctype` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";
}
//And id<>'$typeid'
$needRel = false;
$dtp2 = new DedeTagParse();
$dtp2->SetNameSpace("field","[","]");
$dtp2->LoadSource($innertext);
$dsql2 = clone $dsql;
$dsql->SetQuery($sql);
$dsql->Execute();
$line = $row;
//检查是否有子栏目,并返回rel提示(用于二级菜单)
if(ereg(':rel', $innertext)) $needRel = true;
if(empty($sql)) return '';
$dsql->SetQuery($sql);
$dsql->Execute();
$totalRow = $dsql->GetTotalRow();
$GLOBALS['autoindex'] = 0;
for($i=0;$i < $line;$i++)
{
if($col>1) $likeType .= "<dl>\r\n";
for($j=0;$j<$col;$j++)
{
if($col>1) $likeType .= "<dd>\r\n";
if($row=$dsql->GetArray())
{
$row['sonids'] = $row['rel'] = '';
if($needRel)
{
$row['sonids'] = GetSonIds($row['id'], 0, false);
if($row['sonids']=='') $row['rel'] = '';
else $row['rel'] = " rel='dropmenu{$row['id']}'";
}
//处理同级栏目中,当前栏目的样式
if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )
{
if($currentstyle!='')
{
$linkOkstr = $currentstyle;
$row['typelink'] = GetOneTypeUrlA($row);
$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);
$likeType .= $linkOkstr;
}
}else
{
$row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
if(is_array($dtp2->CTags))
{
foreach($dtp2->CTags as $tagid=>$ctag){
if(isset($row[$ctag->GetName()]))
{
$dtp2->Assign($tagid,$row[$ctag->GetName()]);
}
elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
{
$dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2));
}
}
}
$likeType .= $dtp2->GetResult();
}
}
if($col>1) $likeType .= "</dd>\r\n";
$GLOBALS['autoindex']++;
}//Loop Col
if($col>1)
{
$i += $col - 1;
$likeType .= " </dl>\r\n";
}
}//Loop for $i
reset($dsql2);
$dsql->FreeResult();
return $likeType;
}
function lib_channel_son($ctag,$typeid = 0,$dsql2)
{
$attlist = "row|100,col|1,currentstyle|";
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$innertext = $ctag->GetInnerText();
$dsql3 = clone $dsql2;
$likeType = '';
//if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
if($typeid==0) {
return '';
}
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
From dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
//And id<>'$typeid'
$dtp2 = new DedeTagParse();
$dtp2->SetNameSpace("field","[","]");
$dtp2->LoadSource($innertext);
$dsql2->SetQuery($sql);
$dsql2->Execute();
$line = $row;
for($i=0;$i < $line;$i++)
{
if($col>1) $likeType .= "<dl>\r\n";
for($j=0;$j<$col;$j++)
{
if($col>1) $likeType .= "<dd>\r\n";
if($row=$dsql2->GetArray())
{
$row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
if(is_array($dtp2->CTags))
{
foreach($dtp2->CTags as $tagid=>$ctag){
if(isset($row[$ctag->GetName()]))
{
$dtp2->Assign($tagid,$row[$ctag->GetName()]);
}
elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
{
$dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql3));
}
}
}
$likeType .= $dtp2->GetResult();
}
if($col>1) $likeType .= "</dd>\r\n";
}//Loop Col
if($col>1)
{
$i += $col - 1;
$likeType .= " </dl>\r\n";
}
}//Loop for $i
reset($dsql3);
$dsql2->FreeResult();
return $likeType;
}
?>
模板调用 [field:sonchannel0] [/field:sonchannel0] 这个是用来取子栏目用得(使用[sonchannel+数字] 作为标签名是为了防止嵌套的时候无 确解析标签)这个的作用就是当你的栏目有很多子栏目无限分级的时候方便你取子栏目的
例子
{dede:channel type='son' typeid='22'}
[field:typename/]
<ul>
[field:sonchannel0]
<li><a href="[field:typelink/]">[field:typename/]</a></li>
[field:sonchannel1]
<li><a href="[field:typelink/]">---[field:typename/]</a></li>
[field:sonchannel2]
<li><a href="[field:typelink/]">===[field:typename/]</a></li>
[field:sonchannel3]
<li><a href="[field:typelink/]">===[field:typename/]</a></li>
[/field:sonchannel3]
[/field:sonchannel2]
[/field:sonchannel1]
[/field:sonchannel0]
</ul>
{/dede:channel}
本文标签:织梦cms标签
很赞哦! ()
相关教程
- 织梦标签{global.cfg_templets_skin}不解析地址的解决方法
- 织梦标签tag怎么显示每个tag相应的文章数量
- 织梦标签{dede:productimagelist}图集添加数字编号(dedecms)
- 织梦标签artlist与list有什么不同
- 织梦标签调用指定栏目内容的实现方法
- 设置dedecms织梦标签[field:global.autoindex/]初始值的方法
- 在织梦标签中怎么使用Runphp调用其他变量
- dedecms织梦标签参数说明
- 织梦标签{dede:channel type='son'} 调用栏目标签用法
- dede织梦标签时间标签调用详解
- 适合企业站的织梦标签大全归类整理
- dede织梦标签autoindex使用方法介绍
图文教程
织梦网站被黑,教你如何清楚90sec病毒完整版
最近好像有点少听见90sec病毒攻击的了,不过在8、9月份,90sec病毒攻击织梦网站很疯狂,基本上一夜倒了一大片,本人维护的两个公司网站也没有一个幸免。
dede织梦会员登录或退出跳转到首页的方法
会员在主页登陆后,默认会跳转到会员中心,如果我们想登陆后,跳转到网站主页,那么就请参考下面的方法实现织梦DeDeCms会员登录或退出跳转到首页。
织梦cms缩略图失真模糊的解决方法实例
本文主要讲解了织梦DedeCMS缩略图失真模糊的解决方法,由于织梦dedecms默认只生成一个规格大小的缩略图,而往往在一个站不同页面内需要的缩 略图大小不一致
织梦CMS时间日期时间戳调用标签,dedecms时间标签大全
DEDECMS利用strftime()函数格式化时间的所有参数详解,包括年份日期进制、小时格式等,大家收藏吧,呵.日期时间格式 (利用strftime()
相关源码
-
(自适应)品牌创意设计作品工作室pbootcms模板下载该模板适用于品牌策划、艺术设计、广告创意公司官网,亦可通过替换图文快速适配其他行;高端创意设计公司工作室网站源码极简代码架构、艺术化视觉布局、企业级功能扩展性。查看源码 -
(PC+WAP)蓝色自动电动闸门伸缩门类网站pbootcms模板下载为电动闸门、自动伸缩门企业设计的响应式网站模板,突出产品展示与技术优势,助力门控设备企业建立专业数字化形象。手工编写DIV+CSS结构,代码精简高效,无冗余代码干扰,加载速度更快。查看源码 -
帝国cms7.2淘宝客导购自媒体博客网站模板源码本模板基于帝国CMS7.2内核深度开发,为淘宝客、商品导购类自媒体及博客网站设计。通过可视化后台管理,可快速搭建具备商品推荐、比价功能的内容平台,帮助用户实现流量高效转化。查看源码 -
(自适应响应式)蓝色环保机械设备网站pbootcms模板HTML5源码下载基于PbootCMS的生态环境技术展示平台,通过内容调整可应用于新能源设备、污水处理、空气净化等环保相关领域。设备参数采用对比表格展示,技术原理支持图文混排;查看源码 -
(自适应响应式)高端家用办公家具家居桌椅pbootcms模板下载为办公家具企业设计的响应式网站模板,涵盖产品展示、案例呈现、企业介绍等核心模块。通过可视化后台可快速发布实木桌椅、系统家具、办公屏风等产品信息,帮助客户直观了解材质参数与空间搭配方案。查看源码 -
(自适应)中英文双语外贸扬声器音响喇叭话筒网站模板免费下载为音响设备外贸企业设计的中英文双语网站模板,基于PbootCMS内核开发。适配扬声器系统、音频设备等产品的国际化展示需求查看源码
| 分享笔记 (共有 篇笔记) |
