帝國cms常用標籤匯總_php執行個體

來源:互聯網
上載者:User
判斷會員是否登入

<?phpif(!$_COOKIE[ecmsmlusername]){$srr="登入可見";}else{$srr="[!--lbsly--]";}?>
[!--news.url--]skin/default/[e:loop={"select classid,classname,bname from phome_enewsclass where classid='$GLOBALS[navclassid]'",1,24,0}]<?=$bqr[bname]?>[/e:loop][e:loop={"select * from phome_enewsclass where classid='$GLOBALS[navclassid]'",1,24,0}]<?=$bqr[bname]?>[/e:loop]<?php$fcr=explode('|',$class_r[$GLOBALS[navclassid]][featherclass]);$topbclassid=$fcr[1]?$fcr[1]:$GLOBALS[navclassid];//取得當前欄目的頂級欄目ID$rs=$empire->fetch1("select * from phome_enewsclass where classid=$topbclassid");?>_<?=$rs['bname']?>_<?=$public_r[sitename]?> 頂級欄目名稱+網站標題<?=$class_r[$GLOBALS[navclassid]][bname]?> 得到當前欄目的名稱[!--pagetitle--]  或  <?=$class_r[$GLOBALS[navclassid]][bname]?>
isgood=1 一級推薦firsttitle=1 一級頭條[e:loop={10,3,0,0}] 10當前欄目,3顯示條數,[e:loop={4,1000,0,1,'leib="樓市快訊"','id DESC'}] 1有圖片的顯示。[e:loop={"select * from phome_ecms_xtgg where firsttitle=1 order by id DESC limit 20",6,24,0}]<?=$bqno?> [!--no.num--] 迴圈序號<?=$bqsr['titleurl']?> <?=$bqr[title]?> <?=esub($bqr[title],8)?>[/e:loop]

<?=DoWapRepNewstext($r[newstext])?>

時間調用標籤:<?=date("Y-m-d",$bqr['newstime'])?>


列表頁

您當前的位置:[!--newsnav--]

[!--no.num--]

[!--show.listpage--]

內容頁

[!--info.next--]下一篇 [!--info.pre--]上一篇

萬能標籤用[!--onclick--] 靈動標籤用<?=$bqr[onclick]?> 點擊量

複製代碼 代碼如下:
$titleurl=sys_ReturnBqTitleLink($navinfor); 獲得當前頁面的網址
$url = "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF']; 獲得當前頁面的網址

sql語句

複製代碼 代碼如下:
<?php
//報名人數
$num=$empire->gettotal("select count(*) as total from phome_enewsfeedback where kft='".$navinfor[title]."'");
?>

帝國CMS經常用到的調用sql語句:

請注意,如果是帝國7.0版本的,需要將checked=1去掉

複製代碼 代碼如下:
  1,根據最新文章 select * from [!db.pre!]ecms_news where checked=1 order by newstime desc limit 10
  2,根據推薦文章 select * from [!db.pre!]ecms_news where checked=1 and isgood=1 order by newstime desc limit 10
  3,根據熱門文章 select * from [!db.pre!]ecms_news where checked=1 order by onclick desc limit 10
  4,根據頭條新聞 select * from [!db.pre!]ecms_news where checked=1 and firsttitle=1 order by newstime desc limit 10
  5,根據評論排行 select * from [!db.pre!]ecms_news where checked=1 order by plnum desc limit 10
  6,根據digg排行 select * from [!db.pre!]ecms_news where checked=1 order by diggtop desc limit 10
  7,根據投票排行 select * from [!db.pre!]ecms_news where checked=1 order by votenum desc limit 10
  8,根據下載排行 select * from [!db.pre!]ecms_news where checked=1 order by totaldown desc limit 10
  9,根據評分排行 select * from [!db.pre!]ecms_news where checked=1 order by infopfen desc limit 10

小技巧收錄:

php三元條件運算子:

複製代碼 代碼如下:
<?=$bqr['ftitle']?$bqr['ftitle']:$bqr['title']?>

靈動或者php查詢調用編輯器內容的時候要加stripslashes刪除反斜線比如:

複製代碼 代碼如下:
<?=stripslashes($r['newstext'])?>

內容頁當前資訊ID:

複製代碼 代碼如下:
$navinfor['id']

列表內容範本資訊ID:

複製代碼 代碼如下:
$r['id']

當前欄目名:

複製代碼 代碼如下:
$class_r[$GLOBALS['navclassid']]['classname'];

當前欄目父欄目:

複製代碼 代碼如下:
$class_r[$GLOBALS['navclassid']]['bclassid'];

當前欄目別名:

複製代碼 代碼如下:
$class_r[$GLOBALS['navclassid']]['bname'];

當前欄目子欄目:

複製代碼 代碼如下:
$class_r[$GLOBALS['navclassid']]['sonclass'];

當前欄目子判斷是否為終級欄目:

複製代碼 代碼如下:
$class_r[$GLOBALS['navclassid']]['islast'];

當前欄目是否有已審核資訊:

複製代碼 代碼如下:
$GLOBALS['num']==0為沒有資訊

帝國cms中引入php路徑寫法(例子是檔案在根目錄)

複製代碼 代碼如下:
<?php include(ECMS_PATH."./bottom.php");?>

排除置頂、頭條、推薦等,sql附加條件:

複製代碼 代碼如下:
'istop=0 and isgood=0 and firsttitle=0'

上上級欄目id:

<?php$bclassid=$class_r[$GLOBALS[navclassid]][bclassid];$bbclassid=$class_r[$bclassid][bclassid];echo $bbclassid;?>$bbclassid就是上上級父欄目id

投稿、登陸、反饋、留言等之後跳轉指定頁面:

複製代碼 代碼如下:

統計資訊被收藏數:

複製代碼 代碼如下:
<?
$favas=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsfava where id='$navinfor[id]' and classid='$GLOBALS[navclassid]'");
?>
<?=$favas?>就是這條資訊的收藏數

列表、結合項判斷當前沒有資訊給出提示:

<?
if($GLOBALS['num']=='0'){
?>

對不起,暫時沒有任何資訊!


<?
}else{
?>
[!--empirenews.listtemp--][!--empirenews.listtemp--]
<?
}
?>
[/code]

動態使用:

網站名稱:<?=$public_r['sitename']?>
網站地址:<?=$public_r['newsurl']?>

帝國自身的時間轉換函式:

複製代碼 代碼如下:
<?=format_datetime($bqr[newstime],'Y-m-d')?>

此函數內建判斷,比較不錯,推薦。

判斷內容是否有圖片,沒有圖片則顯示文中廣告 有圖片則不顯示:

複製代碼 代碼如下:
<?php
$string=$navinfor['newstext'];//內容欄位
$some="$num=explode($some,$string);
if(count($num)>1){//判斷內容中是否有圖片
?>
[!--newstext--]
<?
}else{
?>
我是廣告
[!--newstext--]
<?
}
?>

截取加過濾標籤:

複製代碼 代碼如下:
<?=esub(htmlspecialchars(strip_tags($navinfor[newstext])),160)?>

內容頁或靈動標籤支援標題屬性
內容頁:

複製代碼 代碼如下:
<?=DoTitleFont($navinfor[titlefont],$navinfor[title])?>

靈動標籤:

複製代碼 代碼如下:
<?=DoTitleFont($bqr[titlefont],$bqr[title])?>

標題截取字數+標題屬性:

複製代碼 代碼如下:
<?=DoTitleFont($bqr[titlefont],esub($bqr[title],32,'...'))?>

以上所述就是本文的全部內容了,希望大家能夠喜歡。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.