XF 1.2 <xen:helper snippet> Can I snip the last four characters in a text

Marcus

Well-known member
Is there a way to snip the last four charactes of a string with a template helper? Like Bank Account Number 02349234234xxxx?

Or is there a template helper that turns the string around, then I strip the first four characters, and turn it around again.
 

Chris D

XenForo developer
Staff member
Code:
{xen:string wordtrim, $number, 11, 0, xxxx}
Parameters:
  1. $number = the string
  2. $maxLength = the maximum length of the string (not including $elipses)
  3. $offset = starting position
  4. $elipses = string to append to end of the string
Only problem with it is having to know the length of the string. But there's some template functions to calculate that too, I think. But hopefully the length of the strings are predictable.
 
D

Deleted member 55687

Guest
$elipses = string to append to end of the string
as i just recognized: if you use wordtrim with a starting Position the $elipses is also attached to the front of the string - means that

Code:
{xen:string wordtrim, 'http://www.thisisarealverylongurl.com', 18, 7, '...'}
gives ...www.thisisarealver... instead of www.thisisarealver...

is this on purpose or as designed? ;)
 
Top