Fixed Template modification RegEX not working as expected

Siropu

Well-known member
Affected version
2.2
I have this TM in thread_view in 2.1 that doesn't work as expected in 2.2. Basically, "insert 1" is added but not "insert 2". The TM test shows that the modification is applied successfully but the actual result is not.

Code:
#(<xf:foreach loop="\$posts" value="\$post">)(.*)(</xf:foreach>)#sU

Code:
$1
     insert 1
$2
     insert 2
$3
 
We've changed that template slightly in XF 2.2.

It has been changed so that the <xf:foreach> has an <xf:else /> condition, e.g.

HTML:
<xf:foreach loop=" ... ">
    ...
<xf:else />
    ...
</xf:foreach>

Which is a slightly shorter version of:

HTML:
<xf:if is="$posts is not empty">
    <xf:foreach loop=" ... ">
        ...
    </xf:foreach>
<xf:else />
    ...
</xf:if>

What you're actually seeing when this is compiled out is equivalent to

HTML:
<xf:foreach loop=" ... ">
    insert 1
    ...
<xf:else />
    ...
    insert 2
</xf:foreach>

In other words, you'd only see insert 2 if the $posts var was empty.

We'll look to see if there's an appropriate way around this.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.0 RC2).

Change log:
Adjust logic of thread_view template so certain template modifications are applied more consistently.
There may be a delay before changes are rolled out to the XenForo Community.
 
We've adjusted this to basically be automatically backwards compatible with XF 2.1 so it should automatically work as expected after updating to XF 2.2 RC2.

As an added bonus, we've also added some template extension points in those locations like we have done in other parts of the template which would be particularly useful if you're developing a full thread type.
 
Top Bottom