`

帝国CMS 封面、列表页调用商品简介字数截取

 
阅读更多

在帝国CMS 封面、列表页调用商品简介时,商品简介(默认字段名:intro,字段标示:简单描述,下面称为“简单描述”)字数无法截取。
刚开始使用标签模板,
页面内容模板:

[!--empirenews.listtemp--]
<!--list.var1-->
[!--empirenews.listtemp--]

 

列表内容模板(list.var) :

<DIV class="browse_section">
<H3>
<a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a>
</H3>
<a href="[!--titleurl--]" target="_blank"><img width="80" height="60" src="[!--titlepic--]" alt="[!--oldtitle--]" /></a>
[!--intro--]
<p align=right><A href="[!--titleurl--]" title="[!--oldtitle--]">详细信息 »</A>
<DIV class=clear>

 

注意:简单描述调用为[!--intro--],但是无法截取字数,使用下图中的“简介截取字数”不能实现。

 



 

于是,改变方式,使用灵动标签。具体如下:

[e:loop={'selfinfo',10,0,0}]
<DIV class="browse_section">
<H3>
<a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a>
</H3>
<a href="<?=$bqsr['titleurl']?>" target="_blank"><img width="80" height="60" src="<?=$bqr['titlepic']?>" alt="<?=$bqr['oldtitle']?>" /></a>
<?=esub($bqr['intro'],150,'......')?>
<p align=right><A href="<?=$bqsr['titleurl']?>" title="<?=$bqr['oldtitle']?>">详细信息 »</A>
<DIV class=clear>
[/e:loop]

 

其中:<?=esub($bqr['intro'],150,'......')?>


原始为:<?=$bqr['intro']?>

更改为:<?=esub($bqr['intro'],150,'......')?>
注意添加esub(),

其中:intro为简单描述字段名,150为截取字数,'......'为添加省略号,省略号需要添加引号。

  • 大小: 20.2 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics