|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
craigfh Smarty n00b
Joined: 23 Feb 2009 Posts: 4
|
Posted: Mon Feb 23, 2009 1:57 pm Post subject: Display Certain Number of Characters |
|
|
I am trying to only display a certain number of characters from dbase field otherwise it is way to long.
For example I have a description that is 500 characters and only want to diplsy the fisrt 30.
Is there a way to take this?
{$list[itm].id}
and maybe add a pipe and the number of characters to display or do I have to do it in PHP another way.
{$list[itm].description | charcters:30;}
thanks
Craig |
|
Back to top |
|
jothirajan Smarty Pro
Joined: 06 Feb 2009 Posts: 114 Location: India
|
Posted: Mon Feb 23, 2009 2:04 pm Post subject: |
|
|
HP
Code: | {$list[itm].description | stripslashes|wordwrap:30:"\n":true} |
>>> This will show all the result in the next|next row
Code: |
{$list[itm].description|truncate:30}
{$list[itm].description|truncate:30:""}
{$list[itm].description|truncate:30:"---"}
{$list[itm].description|truncate:30:"":true}
{$list[itm].description|truncate:30:"...":true}
|
>>> This will help for you....
Get me if you want more...
Happy coding
JO |
|
Back to top |
|
craigfh Smarty n00b
Joined: 23 Feb 2009 Posts: 4
|
Posted: Mon Feb 23, 2009 3:33 pm Post subject: |
|
|
{$list[itm].description | stripslashes|wordwrap:30:"\n":true}
In the above case does it mean it will just not show any text after 30 characters?
Because this is a drop down menu if there is more than 30 charecters is screws up the menu.
I am trying to only have one row of text no longer the 30.
thanks for your help.
Craig |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Feb 23, 2009 5:13 pm Post subject: |
|
|
use the truncate modifier. |
|
Back to top |
|
jothirajan Smarty Pro
Joined: 06 Feb 2009 Posts: 114 Location: India
|
Posted: Tue Feb 24, 2009 5:48 am Post subject: |
|
|
craigfh wrote: | {$list[itm].description | stripslashes|wordwrap:30:"\n":true}
In the above case does it mean it will just not show any text after 30 characters?
Because this is a drop down menu if there is more than 30 charecters is screws up the menu.
I am trying to only have one row of text no longer the 30.
thanks for your help.
Craig |
>>> Use the above said truncate functionality......This is good for you
Thanks
Happy coding |
|
Back to top |
|
jothirajan Smarty Pro
Joined: 06 Feb 2009 Posts: 114 Location: India
|
Posted: Fri Dec 17, 2010 10:54 am Post subject: |
|
|
{$RES_Q_RECORD_SINGLE.0.page_description|truncate:230|wordwrap:15:"\n":true}
>> Will also help |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|