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

xen:raw with xen:helper wordtrim?

Jaxel

Well-known member
#1
I want to use wordtrim on a raw text field. However, the built-in wordtrim helper uses htmlspecialchars, so it inherently cant be used with raw text. Does XF have a helper for this?
 

Snog

Well-known member
#2
In a template? Yes..
Code:
{xen:helper wordtrim, Your_String, Trim_Length}
In PHP...
Code:
XenForo_Helper_String::wholeWordTrim(Your_String, Trim_Length)
I don't see anything in the php code about htmlspecialchars. I must be blind. :)
 

Jaxel

Well-known member
#3
I don't see anything in the php code about htmlspecialchars. I must be blind. :)
XenForo_Template_Helper_Core
Code:
    public static function helperWordTrim($string, $trimLength)
    {
        return htmlspecialchars(XenForo_Helper_String::wholeWordTrim($string, $trimLength));
    }
 

Snog

Well-known member
#4
OK, I'm blind. :D

Have you tried setting up your own helper that calls XenForo_Helper_String::wholeWordTrim($string, $trimLength) without htmlspecialchars?

Code:
public static function helperYourHelper($string, $trimLength)
{
          return XenForo_Helper_String::wholeWordTrim($string, $trimLength);
}
 
Last edited: