详情页

帝国CMS灵动标签显示标题属性、截取标题字数

时间:2024年04月24日

编辑:佚名

帝国cms采用灵动标签时,我们一般用<?=$bqr[title]?>输出标题,如下图:
[e:loop={"select title,titleurl from phome_ecms_news where `classid` = '$GLOBALS[navclassid]' order by newstime",1,24,0}]<li><a href="<?=$bqr[titleurl]?>"><?=$bqr[title]?></a></li>[/e:loop]
一,帝国cms灵动标签截取标题字数的方法:
① 将上面的
<?=$bqr[title]?>换成<?=esub($bqr[title],30)?>
,这里面的30代表字节数,也就是显示15个汉字
②  需要显示…省略号则使用以下代码:
<?=esub($bqr[title],32,'…')?>
③需要截取[!–class.intro–]的话需要先PHP查询数据库表,然后截取
<?php
$fr=$empire->fetch1("select intro from {$dbtbpre}enewszt where ztid='$GLOBALS[navclassid]' ");
?>
<?=esub($fr[intro],10,'…')?>
二,帝国cms灵动标签显示标题属性的方法:
1,在SQL语句中,将titlefont字段也要选取出来:select titlefont,title,titleurl from......
2,将上面的<?=$bqr[title]?>换成<?=DoTitleFont($bqr[titlefont],$bqr[title])?>
三,帝国cms灵动标签又要显示标题属性,又要截取标题字数的方法:
将一、二方法综合一下,将<?=$bqr[title]?>换成<?=DoTitleFont($bqr[titlefont],esub($bqr[title],30))?>
相关文章
猜你需要