网站推广三步走:十秒注册 -> 提交网站 -> 快速审核 -> 带来无限流量和外链 -> 点入及点出一次即可排名第一位

当前位置:快马目录网 » 站长资讯 » 站长教程 » 文章详细 订阅RssFeed

35dir源码怎么截取网站标题

来源:快马导航网 浏览:151次 时间:2023-04-28

简介:35dir源码怎么截取网站标题

修改方式:

在你的模版页面,需要截取限制标题的长度地方 

例如{#$art.art_title#} 把这个标签里面添加{#$art.art_title|truncate:限制的字数:""#}

就可以了 

关于truncate函数的使用方法参考如下:

truncate 
截取



Parameter Position参数位置 Type参数类型 Required必需 Default默认 Description描述
1 integer No 80 This determines how many characters to truncate to.
截取字符的数量
2 string No ... This is the text to append if truncation occurs.
截取后追加在截取词后面的字符串
3 boolean No false This determines whether or not to truncate at a word boundary (false), or at the exact character (true).
是截取到词的边界(假)还是精确到字符(真)


This truncates a variable to a character length, default is 80. 
As an optional second parameter, you can specify a string of text to display at the end if the variable was truncated. The characters in the string are included with the original truncation length. 
By default, truncate will attempt to cut off at a word boundary. 
If you want to cut off at the exact character length, pass the optional third parameter of true.

从字符串开始处截取某长度的字符.默认是80个.
你也可以指定第二个参数作为追加在截取字符串后面的文本字串.该追加字串被计算在截取长度中。
默认情况下,smarty会截取到一个词的末尾。
如果你想要精确的截取多少个字符,把第三个参数改为"true"


Example 5-21. truncate
例.截取

index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
$smarty->display('index.tpl');

index.tpl:

{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}

OUTPUT:

Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after...
Two Sisters Reunite after
Two Sisters Reunite after---
Two Sisters Reunite after Eigh
Two Sisters Reunite after E...
以上部分内容参考Smarty 模版引擎的使用方法



推荐站点

  • 夜场招聘网夜场招聘网

    夜场网-夜场招聘网主要提供KTV招聘,酒吧招聘,夜总会招聘,会所预订等服务,我们覆盖全国所有城市,每天时时更新夜场招聘信息,免费开放夜场KTV酒吧商家入驻,提供最好的夜场预订,KTV预订,酒吧预订,欢迎各大夜场老板经理前来免费使用,找夜场找工作就上中国夜场网!

    www.ycktv.net
  • 夜店网夜店网

    夜店网是一个关注中国电子音乐产业以及夜店Club发展的社区平台,用新视角解读现代夜店Club的价值和酒吧文化,夜店网致力于维护和推广中国电子音乐的发展,挖掘国内潜在的DJ电子音乐创作人。

    www.yexx.cn
  • 虎扑网虎扑网

    虎扑是以体育赛事和男性兴趣生活为主的社区网站。专注于NBA赛程、NBA录像、NBA直播、NBA资讯、球员交易、足球、英超、电竞、LPL等全部篮球足球电竞赛事,并提供虎扑步行街社区服务

    www.hupu.com
  • 慧科讯业慧科讯业

    慧科讯业一体化舆情监测系统云平台,基于SaaS的方式为企业提供智能数据平台、营销洞察、舆情洞察、人工智能云、大数据资源库等方面的产品和服务,并通过网络舆情监测为各行各业提供一站式的解决方案。

    www.wisers.com.cn
  • 北青网北青网

    YNET.com北青网

    www.ynet.com
  • 喵领域喵领域

    喵领域为您提供全网最全的森萝财团,喵糖映画,喵写真,风之领域,少女秩序,轻兰映画,二次元,绝对领域小姐姐的写真套图资源。

    www.amlyu.com