XF 2.1 Getting post number within page

AndrewSimm

Well-known member
I have a small ads placement add-on that I created for my site and I am looking to insert ads after post 1, 8, and 15 on each page of a thread. I am currently using isFirstPost to insert after the first post but that does not carry page to page.

Is it possible to manage this within the template modification or do I need to extend the Thread controller and modify $posts after it is fetched from $postList?
 
Just use the regular Xenforo Advertisements option but wrap your ad code in a conditional like this...

After post 1:

HTML:
<xf:if is="$post.position % $xf.options.messagesPerPage == 0">

<!-- ad code here -->

</xf:if>

After post 8:

HTML:
<xf:if is="$post.position % $xf.options.messagesPerPage == 7">

<!-- ad code here -->

</xf:if>

After post 15:

HTML:
<xf:if is="$post.position % $xf.options.messagesPerPage == 14">

<!-- ad code here -->

</xf:if>
 
Back
Top Bottom