1. 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?

Discussion in 'XenForo Development Discussions' started by Jaxel, Jan 5, 2015.

  1. Jaxel

    Jaxel Well-Known Member

    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?
     
  2. Snog

    Snog Well-Known Member

    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. :)
     
  3. Jaxel

    Jaxel Well-Known Member

    XenForo_Template_Helper_Core
    Code:
        public static function helperWordTrim($string, $trimLength)
        {
            return htmlspecialchars(XenForo_Helper_String::wholeWordTrim($string, $trimLength));
        }
     
  4. Snog

    Snog Well-Known Member

    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: Jan 6, 2015

Share This Page