帝國CMS靈動標(biāo)簽e:loop的使用
發(fā)布時(shí)間:2014-06-03 來源:互聯(lián)網(wǎng) 瀏覽: 關(guān)鍵詞:帝國CMS靈動標(biāo)簽
靈動標(biāo)簽 (e:loop)
格式:
[e:loop={欄目ID/專題ID,顯示條數(shù),操作類型,只顯示有標(biāo)題圖片,附加SQL條件,顯示排序}]
模板代碼內(nèi)容
[/e:loop]
模板代碼內(nèi)容
[/e:loop]
例子:
<table width="100%" border="0" cellspacing="1" cellpadding="3">
[e:loop={欄目ID/專題ID,顯示條數(shù),操作類型,只顯示有標(biāo)題圖片,附加SQL條件,顯示排序}]
<tr><td>
<a href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></a>
(<?=date('Y-m-d',$bqr[newstime])?>)
</td></tr>
[/e:loop]
</table>
[e:loop={欄目ID/專題ID,顯示條數(shù),操作類型,只顯示有標(biāo)題圖片,附加SQL條件,顯示排序}]
<tr><td>
<a href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></a>
(<?=date('Y-m-d',$bqr[newstime])?>)
</td></tr>
[/e:loop]
</table>
標(biāo)簽說明:靈動標(biāo)簽是無需做標(biāo)簽?zāi)0澹夷0鍍?nèi)容為PHP代碼,因而更靈活,可以使用php所有處理函數(shù)。使用本標(biāo)簽,需開啟模板支持程序代碼(參數(shù)設(shè)置)。
參數(shù):
- 欄目ID/專題ID:查看欄目ID點(diǎn)這里,查看專題ID點(diǎn)這里,當(dāng)前ID='selfinfo',多個(gè)欄目ID與專題ID可用,號格開,如'1,2'。
- 顯示條數(shù):顯示前幾條記錄。
- 操作類型:具體看操作類型說明。
- 只顯示有標(biāo)題圖片:0為不限制,1為只顯示有標(biāo)題圖片的信息。
- 附加SQL條件:附加調(diào)用條件,如:"title='帝國'"。
- 顯示排序:可指定按相應(yīng)的字段排序,如:"id desc"。
變量說明:
- $bqr:$bqr[字段名]:顯示字段的內(nèi)容
- $bqsr:$bqsr[titleurl]:標(biāo)題鏈接,$bqsr[classname]:欄目名稱,$bqsr[classurl]:欄目鏈接
- $bqno:$bqno:為調(diào)用序號
- $public_r:$public_r[newsurl]:網(wǎng)站地址
常用函數(shù)介紹:
文字截取:esub(字符串,截取長度),例子:esub($bqr[title],30)截取標(biāo)題前30個(gè)字符。
時(shí)間格式:date('格式字串',時(shí)間字段),例子:date('Y-m-d',$bqr[newstime])時(shí)間顯示格式為"2008-10-01"。
實(shí)例1:如果信息為當(dāng)天就加New標(biāo)志
本功能實(shí)現(xiàn)調(diào)用信息時(shí)候如果是當(dāng)天發(fā)布的最新信息顯示New標(biāo)志圖片。
<ul>
[e:loop={欄目ID,顯示條數(shù),操作類型,只顯示有標(biāo)題圖片}]
<?
$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>
[e:loop={欄目ID,顯示條數(shù),操作類型,只顯示有標(biāo)題圖片}]
<?
$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為空如果日期=當(dāng)天則顯示New圖片,用<?=$newimg?>在您想要的適當(dāng)位置調(diào)用。
實(shí)例2:在靈動標(biāo)簽內(nèi)使用SQL
[e:loop={'select * from phome_ecms_news where classid=72 order by id DESC limit 6',6,24,0}],注意倒數(shù)第二個(gè)參數(shù)為24,才可以使用SQL。
[e:loop={'select * from [!db.pre!]ecms_news where classid=72 and type='開發(fā)商' order by id DESC limit 6',6,24,0}]
<li class="class1"> <a ><?=$bqr[title]?></a>
<div class="top_div_myAcafa_u"><?=$bqr[address]?><br />業(yè)務(wù)范圍: <?=$bqr[smalltext]?></div>
</li>
[/e:loop]
<li class="class1"> <a ><?=$bqr[title]?></a>
<div class="top_div_myAcafa_u"><?=$bqr[address]?><br />業(yè)務(wù)范圍: <?=$bqr[smalltext]?></div>
</li>
[/e:loop]
實(shí)例3:如果信息帶有圖片信息,則標(biāo)題上帶有圖片標(biāo)志
[e:loop={'selfinfo',20,0,0}]
<?
$newimg="";
if(!empty($bqr[titlepic]))
{
$newimg="<img src='/uploads/allimg/140603/00102HX1-5.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">詳細(xì)內(nèi)容</a>]
</p>
</td>
<td><?=$bqr[myarea]?></td>
<td><?=date('Y-m-d H:i:s', $bqr[newstime])?></td>
</tr>
[/e:loop]
<?
$newimg="";
if(!empty($bqr[titlepic]))
{
$newimg="<img src='/uploads/allimg/140603/00102HX1-5.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">詳細(xì)內(nèi)容</a>]
</p>
</td>
<td><?=$bqr[myarea]?></td>
<td><?=date('Y-m-d H:i:s', $bqr[newstime])?></td>
</tr>
[/e:loop]
顯示字段用<?=$bqr[字段]?>,$bqsr就幾個(gè)變量:
- $bqsr[titleurl]:標(biāo)題鏈接
- $bqsr[classname]:欄目名稱
- $bqsr[classurl]:欄目鏈接
- $bqsr[titleurl]:標(biāo)題鏈接
- $bqsr[classname]:欄目名稱
- $bqsr[classurl]:欄目鏈接
- 除了這幾個(gè)其他的都用$bqr。
實(shí)例1:
<!--最新300條中點(diǎn)擊率最高的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]
[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]
實(shí)例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相關(guān)度抓取-->
<!-- 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]
<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相關(guān)度抓取-->
<!-- 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]
實(shí)例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]
<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]
責(zé)任編輯:MOKUGE