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

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

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

来源:快马导航网 浏览:42次 时间: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 模版引擎的使用方法



推荐站点

  • 少年科技少年科技

    少年科技工作室官网,致力于Web及原生前后端软件开发,提供多样化服务

    www.snkj.xyz
  • 中国图书网中国图书网

    中图网:网上书店,创办于1998年,通过好书推荐、畅销书、淘书团、特色专题等栏目及各种促销活动,致力于为读者提供价廉物美的正版优质书籍,是爱书人的淘书圣地。

    www.bookschina.com
  • 中国网中国网

    国家重点新闻网站,拥有十个语种独立新闻采编、报道和发布权;第一时间报道国家重大新闻事件;国情信息库服务全球读者了解中国;新闻办公室发布会独家网络直播发布网站;拥有国内外顶级学者专家资源,独家编发各种相关政策解读。

    www.china.com.cn
  • 云自媒云自媒

    云自媒汇聚26万+优质自媒体资源!已为30万+广告主提供软文、微信、朋友圈、微博、视频等社会化媒体营销。投广告就上云自媒!

    www.myunmei.com
  • 夜上海官网夜上海官网

    夜上海官网讲述当地纪实微观生活,个人见闻,随心所阅等主题

    www.sfyue166.com
  • 黑马程序员官网黑马程序员官网

    黑马程序员专注于it培训,开设java培训、鸿蒙开发培训、大数据培训、web前端培训、python培训、嵌入式培训、嵌入式开发培训、人工智能培训、软件测试培训、产品经理培训、智能机器人软件开发培训等多门it培训课程,提供java培训、java开发培训、python开发培训

    www.itheima.com