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

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

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

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



推荐站点

  • 夜上海论坛夜上海论坛

    上海论坛主要介绍上海会所,品茶有关的资讯平台

    www.fff2025.live
  • 十堰秦楚网十堰秦楚网

    秦楚网由十堰宣传部主管、十堰日报传媒集团主办,是十堰市新闻门户网站、湖北省重点新闻网站。目前,网站已发展成为集报纸、新闻网站、移动新媒体、电子商务、专业网站于一体的互联网企业,在全国同行中拥有较强的影响力。

    www.10yan.com
  • 人人视频人人视频

    人人视频APP

    m.yichengwlkj.com
  • 上海后花园上海后花园

    上海都市养生资讯社区位于上海市繁华的商业区,是一家集健康、休闲、养身为一体的高端养生中心。内设多个功能区域,包括桑拿浴、按摩、养生、足疗休闲等,为会员提供一站式的全方位养生服务

    www.ff2020ff.xyz
  • 中国侨网中国侨网

    中国侨网是由中国新闻社主办的面对全球华侨华人提供综合性信息服务的专业网站,是中国内地最大的侨务网络信息平台。中国侨网作为中国最具权威的大型侨务网站,依托全国各省、市、自治区侨务机构所拥有的强大涉侨信息资源,通过华人、中国侨界、留学生、华文教育、侨乡传真等频道,为全球华侨华人提供、经济、社会、教育、文化等各个领域的涉侨新闻及服务信息。

    www.chinaqw.com
  • 学习周刊学习周刊

    为您提供经典美文、优美散文、励志正能量实用好文,同时还有优质课件教案、中考高、高考作文、中考作文指导、作文素材以及诗歌散文等学习资源。

    www.weekdaily.cn