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

XF 1.5 Templates: How do I escape HTML when concatenating a string?

Discussion in 'Styling and Customization Questions' started by Stuart Wright, Jun 18, 2016.

  1. Stuart Wright

    Stuart Wright Well-Known Member

    Hello folks,
    I'm trying to build a string of HTML in a loop.
    The string I want to build in each iteration of the loop is this html
    HTML:
    <li>
              <a href="{xen:link forums, $forum, '_params={$pageNavParams}', 'prefix_id={$prefix.prefix_id}'}">{xen:helper threadPrefix, $prefix, html, ' ({xen:if {$prefixCounts.{$prefix.prefix_id}}, {$prefixCounts.{$prefix.prefix_id}}, 0})'}</a>
    </li>
    
    I'm trying to use
    Code:
    <xen:set var="$prefixHTML" value="{$prefixHTML} the above code"
    to build a string of <li>s, but the double quote in the html needs escaping.
    How can I do this please?
     
  2. Stuart Wright

    Stuart Wright Well-Known Member

    Solved it. This works
    Code:
    <xen:set var="$prefixHTML"><li><a href="{xen:link forums, $forum, '_params={$pageNavParams}', 'prefix_id={$prefix.prefix_id}'}">{xen:helper threadPrefix, $prefix, html, ' ({xen:if {$prefixCounts.{$prefix.prefix_id}}, {$prefixCounts.{$prefix.prefix_id}}, 0})'}</a></li></xen:set>
    <xen:set var="$allPrefixHTML" value="{$allPrefixHTML}{$prefixHTML}" />
    
    but curiously this doesn't
    Code:
    <xen:set var="$allPrefixHTML">{$allPrefixHTML}<li><a href="{xen:link forums, $forum, '_params={$pageNavParams}', 'prefix_id={$prefix.prefix_id}'}">{xen:helper threadPrefix, $prefix, html, ' ({xen:if {$prefixCounts.{$prefix.prefix_id}}, {$prefixCounts.{$prefix.prefix_id}}, 0})'}</a></li></xen:set>
    
     

Share This Page