1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'XenForo Questions and Support' started by Marcus, Jul 31, 2013.

  1. Marcus

    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.
  2. Chris D

    Chris D XenForo Developer Staff Member

    {xen:string wordtrim, $number, 11, 0, xxxx}
    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.
    KiF and Marcus like this.
  3. Timeout

    Timeout Member

    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

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

    is this on purpose or as designed? ;)

Share This Page