Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display limited characters in smarty?

Tags:

smarty

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

like image 440
Mohan Ram Avatar asked Dec 18 '10 09:12

Mohan Ram


People also ask

What is capture in Smarty?

{capture} is used to collect the output of the template between the tags into a variable instead of displaying it. Any content between {capture name='foo'} and {/capture} is collected into the variable specified in the name attribute. The captured content can be used in the template from the variable $smarty.


1 Answers

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.
like image 132
Mohan Ram Avatar answered Sep 28 '22 14:09

Mohan Ram