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

Nesting XenForo template syntax

Discussion in 'XenForo Development Discussions' started by fishb6nes, Sep 13, 2015.

  1. fishb6nes

    fishb6nes Member

    I am looking to display the contents of a post with a certain id on a page as achieved in this tutorial: https://xenforo.com/community/resources/how-to-show-a-post-in-a-page.306/

    However I'd also like to trim the size of said contents. Including the post contents on a page via {xen:raw $post.messageParsed} works perfectly fine. However after having trimmed the contents using {xen:helper snippet, {xen:raw $post.messageParsed}, 165} the message is displayed as plain HTML (e.g. <i> and <br> tags are printed as is). Trying it the other way round {xen:raw {xen:helper snippet, $post.messageParsed, 165}} or {xen:raw ${xen:helper snippet, $post.messageParsed, 165}} gives me an error stating my syntax is invalid. But at this point I'm only guessing.

    Is it possible to do this inside the page template at all or should I trim the contents before they're stored in $post.messageParsed?

    Thank you.​
  2. katsulynx

    katsulynx Well-Known Member

    You're best of trimming the content before you pass it to the template. Keep in mind that you might break syntax if you cut a closing tag however.
  3. Zenexer

    Zenexer Active Member

    You can't truncate HTML. You'll need to either get fancy with regex hacks or use some lightweight XML parsing.

Share This Page