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

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?
 
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>
 
Back
Top Bottom