How to display limited characters in smarty?

Mohan Ram picture Mohan Ram · Dec 18, 2010 · Viewed 9.5k times · Source

I am receiving a paragraph content in smarty. While displaying i need to display only 25 characters how to limit characters in smarty.

<p>{$myresult}</p>

Now i am simply displaying. How to display only 25 characters from smarty content

Answer

Mohan Ram picture Mohan Ram · Dec 18, 2010

Usage of Truncate in smarty...

CODES

{$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}

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