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

{xen:helper wordTrim function breaks the smilies on custom message

Discussion in 'XenForo Development Discussions' started by wang, Jan 7, 2016.

  1. wang

    wang Well-Known Member

    I working on an add on and I have come across this issue that I cannot seem to find the solution. I am trying to display smilies on a custom page and that works. But when I try to show an excerpt of the message, then all smilies break into html code. They are not parsed correctly anymore.

    This is the code that I am using to parse the smilies.

    HTML:
    {xen:raw $message.messageParsed}
    This works fine. But when I add the {xen:helper wordTrim function to show only 100 characters, it is not working anymore.

    This is how I am adding it.

    HTML:
    {xen:string nl2br, {xen:helper wordTrim, {xen:raw $message.messageParsed}, 100}}
    I have been trying to find a solutions for hours now, but no luck. Some help would be much appreciated.
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    It's the order of the operations here that's the problem. Something like this would work:
    Code:
    {xen:raw {xen:string nl2br, {xen:helper wordTrim, {$message.messageParsed}, 100}}
     
    wang likes this.
  3. wang

    wang Well-Known Member

    Thank you very much for your help sir. I truly do appreciate it :) It was very frustrating to me that I could not find a solution.

    I get a template syntax error when I tried that. I tried a few other combination and it was the same result.
     
  4. wang

    wang Well-Known Member

    I found a way to fix this. I removed the wordTrim function from the template, and I used the XenForo_Helper_String::wholeWordTrim() function to the my viewer php file instead, like this.

    PHP:
    $message.messageParsed $parser>render(XenForo_Helper_String::wholeWordTrim($message.messageParsed ,100));
    I hope that this can help other users too, who will run into the same glitch I did.

    I want to thank again @Chris D for his help. Thank you sir :)
     

Share This Page