帝国CMS灵动标签e:loop的使用

帝国CMS灵动标签e:loop的使用,第1张

概述灵动标签(e:loop)格式:[e:loop={栏目ID/专题ID,显示条数, *** 作类型,只显示有标题图片,附加SQL条件,显示排序}]模板代码内容[/e:loop]例子:<table width="100%" border="0" c

灵动标签 (e:loop)
格式:

[e:loop={栏目ID/专题ID,显示条数, *** 作类型,只显示有标题图片,附加sql条件,显示排序}]
模板代码内容
[/e:loop]

例子:

<table wIDth="100%" border="0" cellspacing="1" cellpadding="3">[e:loop={栏目ID/专题ID,显示条数, *** 作类型,只显示有标题图片,附加sql条件,显示排序}]<tr><td><a href="<?=$bqsr[Titleurl]?>" target="_blank"><?=$bqr[Title]?></a>(<?=date('Y-m-d',$bqr[newstime])?>)</td></tr>[/e:loop]</table>

标签说明:灵动标签是无需做标签模板,且模板内容为PHP代码,因而更灵活,可以使用PHP所有处理函数。使用本标签,需开启模板支持程序代码(参数设置)。

参数:

栏目ID/专题ID:查看栏目ID点这里,查看专题ID点这里,当前ID='selfinfo',多个栏目ID与专题ID可用,号格开,如'1,2'。

显示条数:显示前几条记录。

*** 作类型:具体看 *** 作类型说明。

只显示有标题图片:0为不限制,1为只显示有标题图片的信息。

附加sql条件:附加调用条件,如:"Title='帝国'"。

显示排序:可指定按相应的字段排序,如:"ID desc"。

变量说明:

$bqr:$bqr[字段名]:显示字段的内容

$bqsr:$bqsr[Titleurl]:标题链接,$bqsr[classname]:栏目名称,$bqsr[classurl]:栏目链接

$bqno:$bqno:为调用序号

$public_r:$public_r[newsurl]:网站地址

常用函数介绍:

文字截取:esub(字符串,截取长度),例子:esub($bqr[Title],30)截取标题前30个字符。

时间格式:date('格式字串',时间字段),例子:date('Y-m-d',$bqr[newstime])时间显示格式为"2008-10-01"。

实例1:如果信息为当天就加New标志

本功能实现调用信息时候如果是当天发布的最新信息显示New标志图片。

<ul>[e:loop={栏目ID,显示条数, *** 作类型,只显示有标题图片}]<?$newimg="";if(date("m-d",$bqr[truetime]) == date("m-d")){    $newimg = "<img src='New图片地址'>";}?> <li><a href="<?=$bqsr[Titleurl]?>" target="_blank"><?=sub($bqr[Title],0,10,false)?></a><?=$newimg?></li>[/e:loop]</ul>

说明:首先定义newimg为空如果日期=当天则显示New图片,用<?=$newimg?>在您想要的适当位置调用。

实例2:在灵动标签内使用sql

[e:loop={'select * from phome_eCMS_news where classID=72 order by ID DESC limit 6',6,24,0}],注意倒数第二个参数为24,才可以使用sql。

[e:loop={'select * from [!db.pre!]eCMS_news where classID=72 and type='开发商' order by ID DESC limit 6',6,24,0}]    <li class="class1"> <a href='http://www.hkqipilang.acafa.com/' target=_blank Title='<?=$bqr[Title]?>'><?=$bqr[Title]?></a>        <div class="top_div_myAcafa_u"><?=$bqr[address]?><br />业务范围: <?=$bqr[smalltext]?></div>    </li>[/e:loop]
实例3:如果信息带有图片信息,则标题上带有图片标志
[e:loop={'selfinfo',20,0,0}]<?$newimg="";if(!empty($bqr[Titlepic])){    $newimg="<img src='http://bbs.zhnews.net/bbs/static/image/filetype/image_s.gif' />";}?> <tr class="even"><td class="Title"><h1><a href="<?=$bqsr[Titleurl]?>" target="_blank"><?=sub($bqr[Title],0,24,false)?></a> <?=$newimg?></h1><p class="intro"><?=$bqr[smalltext]?>[<a Title="阅读全文" href="<?=$bqsr[Titleurl]?>" target="_blank">详细内容</a>]</p></td><td><?=$bqr[myarea]?></td><td><?=date('Y-m-d H:i:s', $bqr[newstime])?></td></tr>[/e:loop]

显示字段用<?=$bqr[字段]?>,$bqsr就几个变量:

$bqsr[Titleurl]:标题链接

$bqsr[classname]:栏目名称

$bqsr[classurl]:栏目链接

$bqsr[Titleurl]:标题链接

$bqsr[classname]:栏目名称

$bqsr[classurl]:栏目链接 

除了这几个其他的都用$bqr。

实例1:
<!--最新300条中点击率最高的2条-->[e:loop={'select * from (select a.ID,a.Title,a.newspath,a.newstime,b.classpath,b.classname,b.filetype,a.onclick,a.smalltext from '.$dbtbpre.'eCMS_article as a,'.$dbtbpre.'enewsclass b where a.classID=b.classID and a.checked=1 order by a.newstime desc limit 200) as new300 order by  new300.onclick desc limit 2',1,24,0}]<li><a href="[!--news.url--]<?=$bqr[classpath].'/'.$bqr[newspath].'/'.$bqr[ID].$bqr[filetype ]?>" target="_blank" Title="<?=$bqr[Title]?>"><h3><?=sub($bqr[Title],0,30,false)?></h3></a><spn><?=sub($bqr[smalltext],0,150,false)?>……</span></li>[/e:loop]
实例2:
[e:loop={'article',4,20,1}]<div ID="body_left_Panel_Components1_body_No1" class="body_left_Panel_Components1_body_No1"><div ID="body_left_Panel_Components1_body_No1_img" class="body_left_Panel_Components1_body_No1_img"> <a Title="<?=$bqr[Title]?>" href="<?=$bqsr[Titleurl]?>"> <img height="62" wIDth="115" alt="<?=$bqr[Title]?>" src="<?=$bqr[Titlepic]?>"/> </a> </div><div ID="body_left_Panel_Components1_body_No1_text" class="body_left_Panel_Components1_body_No1_text"><ul><!--提高Adsense相关度抓取--><!-- Google_ad_section_start -->                  <?PHP$newimg="";$sql_good=$empire->query("select * from (select a.ID,a.Title,a.newspath,a.newstime,b.classpath,b.classname,b.filetype from ".$dbtbpre."eCMS_article as a,".$dbtbpre."enewsclass b where a.classID=b.classID and a.checked=1 and a.isgood=1 order by a.onclick desc limit 12) as a1 order by length(a1.Title)  limit ".($good_pageSize*$good_limitsize).",".$good_limitsize);$_i=$good_limitsize*$good_pageSize+1;while($info=$empire->fetch($sql_good)){?> <li><img src="[!--news.url--]face/image/<?=$_i?>.gif" alt="<?=$info[Title]?>" wIDth="11" height="9"/><a href="[!--news.url--]<?=$info[classpath].'/'.$info[newspath].'/'.$info[ID].$info[filetype ]?>" target="_blank" Title="<?=$info[Title]?>"><?=sub($info[Title],0,20,false)?></a></li><?PHP        $_i++;}$good_pageSize++;?><!-- Google_ad_section_end --></ul></div></div>[/e:loop]
实例3:
[e:loop={'select classID,classpath,classname from [!db.pre!]enewsclass where classID in ("47","48","49","50","51","52","53","54","55","103","112")  order by classID',1,24,0}]<div ID="body_left_Pane2" class="body_left_Pane2"><div ID="body_left_Pane2_Title" class="body_left_Pane2_Title"><span><h4><a href="[!--news.url--]<?=$bqr[classpath]?>/" Title="<?=$bqr[classname]?>"><?=$bqr[classname]?></a></h4></span><span></span><span></span><?PHP$newimg="";$sql=$empire->query("select classID,classpath,classname from ".$dbtbpre."enewsclass where bclassID=$bqr[classID]  order by classID");while($info=$empire->fetch($sql)){?> <span><a href="[!--news.url--]<?=$info[classpath]?>/" Title="<?=$info[classname]?>"><?=$info[classname]?></a></span><?PHP}?></div><div ID="body_left_Pane2_body" class="body_left_Pane2_body"><div ID="body_left_Pane2_body_left" class="body_left_Pane2_body_left"><div ID="body_left_Pane2_body_left_Title" class="body_left_Pane2_body_left_Title"> <?PHP$newimg="";$sql=$empire->query("select a.*,b.filetype,b.classpath,b.classname from ".$dbtbpre."eCMS_article as a,".$dbtbpre."enewsclass b where a.classID=b.classID and a.checked=1 and a.firstTitle=1 and length(a.Titlepic)>3 and a.classID in (select classID from ".$dbtbpre."enewsclass where bclassID=$bqr[classID]) order by a.newstime desc limit 1");while($info=$empire->fetch($sql)){?> <div ID="body_left_Pane2_body_left_Title_pic" class="body_left_Pane2_body_left_Title_pic"><img src="<?=$info[Titlepic]?>" Title="<?=$info[Title]?>"  wIDth="80" height="60" /></div><div ID="body_left_Pane2_body_left_Title_right" class="body_left_Pane2_body_left_Title_right"><h5><a href="[!--news.url--]<?=$info[classpath].'/'.$info[newspath].'/'.$info[ID].$info[filetype ]?>" target="_blank" Title="<?$info[Title]?>"><?=sub($info[Title],0,20,false)?></a></h5><?=sub($info[smalltext],0,100,false)?>……</div><?PHP}?></div><div ID="body_left_Pane2_body_left_body" class="body_left_Pane2_body_left_body"><ul><?PHP$newimg="";$sql=$empire->query("select a.ID,a.Title,a.newspath,a.newstime,b.classpath,b.classname,b.filetype from ".$dbtbpre."eCMS_article as a,".$dbtbpre."enewsclass b where a.classID=b.classID and a.checked=1 and  a.classID in (select classID from ".$dbtbpre."enewsclass where bclassID='$bqr[classID]'  order by classID)  order by a.onclick desc,a.newstime desc limit ".$limitsize);while($info=$empire->fetch($sql)){if (date("y-m-d",$info[newstime])==date("y-m-d")){$newimg="<Font color=red>".date("m-d",$info[newstime])."</Font>";}else{$newimg=date("m-d",$info[newstime]);} ?> <li><a href="[!--news.url--]<?=$info[classpath].'/'.$info[newspath].'/'.$info[ID].$info[filetype ]?>" target="_blank" Title="<?=$info[Title]?>"><?=sub($info[Title],0,30,false)?></a></li><?PHP}?></ul></div></div><div ID="body_left_Pane2_body_right" class="body_left_Pane2_body_right"><ul><?PHP$newimg="";$sql=$empire->query("select a.ID,a.Title,a.newspath,a.newstime,b.classpath,b.classname,b.filetype,b.classID as b_ID from ".$dbtbpre."eCMS_article as a,".$dbtbpre."enewsclass b where a.classID=b.classID and a.checked=1 and  a.classID in (select classID from ".$dbtbpre."enewsclass where bclassID='$bqr[classID]'  order by classID)  order by a.newstime desc limit ".$limitNewSize);while($info=$empire->fetch($sql)){if (get_date(date("y-m-d"),date("y-m-d",$info[newstime]))<1){$newimg="<img src='[!--news.url--]face/image/new.gif' wIDth='25' height='13'  Title='".date("y-m-d",$info[newstime])."'/>";}else{$newimg="";}?> <li><a href="[!--news.url--]<?=$info[classpath]?>/" Title="<?=$info[classname]?>">[<?=$info[classname]?>]</a><a href="[!--news.url--]<?=$info[classpath].'/'.$info[newspath].'/'.$info[ID].$info[filetype ]?>" target="_blank" Title="<?=$info[Title]?> 日期:<?=date("Y-m-d",$info[newstime])?>"><?=sub($info[Title],0,18,false)?></a><?=$newimg?></li><?PHP}?></ul></div></div></div>[/e:loop]
总结

以上是内存溢出为你收集整理的帝国CMS灵动标签e:loop的使用全部内容,希望文章能够帮你解决帝国CMS灵动标签e:loop的使用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/998996.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-21
下一篇2022-05-21

发表评论

登录后才能评论

评论列表(0条)