Get Smarty

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

truncate

指定したキャラクタ数(デフォルトは80)で変数を切り捨てます。 第2パラメータには、変数が切り捨てられた時に終端に付加する文字列を指定する事が出来ます。 指定する文字列の長さは元の切り捨ての長さの中に含まれます。 デフォルトでは、truncate は単語の境界で切り捨てを行います。 厳密なキャラクタ数で切り捨てたい場合には第3パラメータに TRUE を渡します。

パラメータの位置 必須 デフォルト 概要
1 integer No 80 切り捨てを行うキャラクタ数
2 string No ... 切り捨てが発生した際に終端に付加するキャラクタ。 この長さは切り捨て長さの設定に含まれません。
3 boolean No FALSE 切り捨てを単語の境界で行うか(FALSE)、厳密なキャラクタ数で行うか(TRUE)
4 boolean No FALSE 切り捨てを文字列の終端で行うか(FALSE)、 文字列の中盤で行うか(TRUE)。この設定がTRUEの場合、 単語の境界が無視されることに注意。

Example 5.21. truncate


<?php
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
?>

   

テンプレート


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

   

出力


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...
Two Sisters Re..ckout Counter.

   

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 15 plus 15? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com
ASP.NET hosting @aspnethosting.co.uk