This bit of code will display an ad on the last post of each page: If the last (or only) page contains less posts than the messages per page setting, the last post will still display the ad.
Code:
<xen:if is="{$post.position} + 1 == {$xenOptions.messagesPerPage} * {$page}">
your ad code
<xen:else />
<xen:if is="{$post.position} == {$totalPosts} - 1">
your ad code
</xen:if>
</xen:if>
This bit of code will display an ad on the last post of each page: If the last (or only) page contains less posts than the messages per page setting, the last post will still display the ad.
Code:
<xen:if is="{$post.position} + 1 == {$xenOptions.messagesPerPage} * {$page}">
your ad code
<xen:else />
<xen:if is="{$post.position} == {$totalPosts} - 1">
your ad code
</xen:if>
</xen:if>