1
2
3
4
5
6
7
8
9
10
11
12
13
1、帝国CMS内容页模版如何调用当前栏目名称和链接
<
a
href="<?=sys_ReturnBqClassname($navinfor,9)?>/">[!--class.name--]</
a
>
调用栏目缩略图的3种情况
(1)列表页中比较简单
[!--classimg--]
(2)内容页调用当前页面所在栏目的缩略图
[e:loop={"select classimg from phome_enewsclass where classid='$GLOBAL[navclassid]'",1,24,0}]
<?=$bqr[classimg]?>
[/e:loop]
(3)封面页调用指定栏目缩略图
[e:loop={"select classid,classname,classimg,intro from phome_enewsclass where classid=11",1,24,0}]
<
img
src="<?=$bqr[classimg]?>" border="0" width="120" height="95" alt="<?=$bqr[classname]?>">
[/e:loop]
1
2
2、调用ID为1的栏目url
<?=$public_r['newsurl'].$class_r[1]['classpath']?>
1
2
3、调用ID为1的栏目名
<?=$class_r[1]['classname']?>
1
2
3
4、[ecmsinfo]'news',10,0,0,18,24,0,"writer='".$navinfor[title]."'",'newstime DESC'[/ecmsinfo]
此万能标题中的news代表所有新闻列表,writer='".$navinfor[title].指的是文章的作者要和标题一样才调用
在模板内获取字段值可通过调用$navinfor[字段名],比如要显示"信息ID字段",那在模板里用:<?=$navinfor[id]?>即可输出(要开启模板支持程序代码)
5、新闻模型按月排行
1
[ecmsinfo]'news',9,0,0,18,3,0,"date_format(from_UNIXTIME(newstime),'%Y-%m') = date_format(now(),'%Y-%m')","onclick DESC"[/ecmsinfo]
新闻模型按周排行
1
[ecmsinfo]'news',9,0,0,18,3,0,"YEARWEEK(from_unixtime(newstime,'%Y-%m-%d')) = YEARWEEK(now())","onclick DESC"[/ecmsinfo]
新闻模型总排行
1
[ecmsinfo]'news',9,0,0,18,3,0,'','onclick DESC'[/ecmsinfo]
6、二级导航下拉菜单:
1
2
3
4
5
6
7
8
9
10
页面模板内容:
<
li
><
a
href
=
"[!--bclassurl--]"
>[!--bclassname--]</
a
>
<
ul
>
[!--empirenews.listtemp--]
<!--list.var1-->
[!--empirenews.listtemp--]
</
ul
>
</
li
>
列表内容模板:<
li
><
a
href
=
"[!--classurl--]"
>[!--classname--]</
a
></
li
>
对应页面调用:[listshowclass]'0',12,0,0[/listshowclass] 数字12是标签id
7、栏目图片调用(标签模板)
1
2
3
页面模板内容:[!--empirenews.listtemp--]
<!--list.var1-->
[!--empirenews.listtemp--]
列表内容模板:<
li
><
a
href
=
"[!--classurl--]"
title
=
"[!--classname--]"
><
img
src
=
"[!--classimg--]"
/></
a
></
li
>
首页调用:[showclasstemp]67,21,0,0[/showclasstemp] 67是id 21是模板
8、带模版的下拉友情链接列表
1
2
3
4
5
6
页面模板内容:
<
select
onchange
=
"window.open(this.options[selectedIndex].value,'','');"
class
=
"selink"
name
=
'friendsite'
>
[!--empirenews.listtemp--]
<!--list.var1-->
[!--empirenews.listtemp--]
</
select
>
列表内容模板:<
option
value
=
'[!--titleurl--]'
>[!--title--]</
option
>
对应页面调用:[ecmsinfo]'select lname as title,lurl as titleurl,lid as id from [!db.pre!]enewslink where classid=1 order by lid limit 50',0,50,0,24,14,0[/ecmsinfo](14是模板标签 第一个50是数量)
9、用if判断内容模板字段为空时:
1、举例:如果字段值来源为空,则显示“小米技术社区 :www.bbsxiaomi.com”
1
2
3
4
5
6
7
8
<?
if
($navinfor['befrom']=="") {
echo '小米技术社区:www.bbsxiaomi.com';
}
else{
echo ''.$navinfor[befrom].'';
}
?>
2、如果作者为空,则不输出任何内容,那么添加样式以及作者
1
2
3
4
5
6
7
8
<?
if
($navinfor['writer']=="") {
echo '';
}
else{
echo '<span>作者:'.$navinfor[writer].'</
span
>';
}
?>
10、按表随机调用
1
2
[ecmsinfo]"select * from phome_ecms_news order by rand() desc limit 6 ",6,18,0,24,2,0[/ecmsinfo]
其中:news为表名,两个6表示调用的数量为6条,18表示标题取18个字符,第一个0表示不显示栏名名,随机调用的操作类型固定为24,2表示模板ID,第二个0标题图片不存在也调用
11、随机调用本栏目下的文章
1
2
[ecmsinfo]"select * from phome_ecms_news where classid='$GLOBALS[navclassid]' order by rand() desc limit 6",6,18,0,24,2,0[/ecmsinfo]
其中:news为表名,两个6表示调用的数量为6条,18表示标题取18个字符,第一个0表示不显示栏名名,随机调用的操作类型固定为24,2表示模板ID,第二个0标题图片不存在也调用
12、帝国cms指定id范围随机调用信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
万能标签:
<?
php
$
randnum
=
10
; //随机数量
$
randids
=
''
;
$
randdh
=
''
;
for($
i
=
1
;$i<=$randnum;$i++)
{
$randids.=$randdh.rand(5000,10000); //1为最小ID,100000为最大ID
$
randdh
=
','
;
}
?>
[ecmsinfo]0,4,44,0,3,34,0,'','id in ('.$randids.')'[/ecmsinfo]
灵动标签
<?
php
$
randnum
=
10
; //随机数量
$
randids
=
''
;
$
randdh
=
''
;
for($
i
=
1
;$i<=$randnum;$i++)
{
$randids.=$randdh.rand(1,100000); //1为最小ID,100000为最大ID
$
randdh
=
','
;
}
?>
[e:loop={栏目ID,显示条数,操作类型,只显示有标题图片,"id in ($randids)"}]
模板代码内容
[/e:loop]
13、随机调用某栏目或者多栏目下的信息(未测试)
1
2
[ecmsinfo]"select * from phome_ecms_article where classid='ID名' order by rand() desc limit 6",6,18,0,24,2,0[/ecmsinfo]
[ecmsinfo]"select * from phome_ecms_news where classid in (id1,id2,id3....) order by rand() desc limit 6 ",6,18,0,24,2,0[/ecmsinfo]
14、调用标题包含“cms”的新闻
1
2
3
[e:loop={'news',10,18,0,"title like '%cms%'",''}]
<
a
href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></
a
><
br
>
[/e:loop]