1
yamipod
truncate string
  • 2005/7/3 22:19

  • yamipod

  • Just popping in

  • Posts: 6

  • Since: 2005/7/3 2


Hi,

I'm using myalbum module. I got a long description of a photo in $photo.description. I would like to truncate it if longer than 100 chars, so edited the myalbum_photo_in_list.html template:

....

<{if strlen($photo.description)>100}>
short descr:
<{substr($photo.description,0,100)}>
<{else}>
<{$photo.description}>
<{/if}>
...


but it's not working, the if clause is correctly evaluated, as 'short descr:' is printed out, but the substr isn't working.

Any help?
Tomas

2
Dave_L
Re: truncate string
  • 2005/7/3 22:45

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


You can replace all of your code with:

<{$photo.description|truncate:100:'...'}>

Reference:http://smarty.php.net/manual/en/language.modifier.truncate.php

Login

Who's Online

179 user(s) are online (118 user(s) are browsing Support Forums)


Members: 0


Guests: 179


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits