XF 1.2 Ad unit below 5th thread in thread list

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 4>
Thanks. This is for messages, but not for threads.

In thread_list template, I need something like this:

Code:
<xen:hook name="thread_list_threads">
<xen:foreach loop="$threads" value="$thread">
<xen:include template="thread_list_item" />
<xen:if is="{$thread.position} % {$xenOptions.discussionsPerPage} == 4">
ad unit
</xen:if>
</xen:foreach>

Is it posible?
 
Oh, I misread.

No, there's no way of doing that using a conditional statement as threads aren't numbered as posts are.

You could try using li:nth-child(5) and doing it that way.
 
Old thread I know...so use CSS style for li:nth-child(5) to take care of this? CSS is not my strong suit obviously, any help to further explain this would be great.
 
@Brogan - any chance you could provide example code for this?

I'd really like to stick in a banner ad every 7th and 14th thread within the thread_list template, and CSS is not my strong suit.

I checked the conditional statements resource, and didn't find anything on this (makes sense given your statement above that threads are numbered differently than posts.)

Too bad we can't just use a template conditional like:
Code:
<xen:if is="{$thread.position} % {$xenOptions.discussionsPerPage} == 7">
 
This is what I ended up with in thread_list that puts my ad after the 5th post in a thread listing after the stickied threads. There may be a better way but this works.

Code:
<xen:foreach loop="$threads" value="$thread" i="$i">
<xen:include template="thread_list_item" />
<xen:if is="!{xen:helper ismemberof, $visitor, 26, 4}">
<xen:if is="{$i} == 5">
 
Last edited:
@SuperJETT Thanks. I hadn't thought of manually getting the thread position myself. Unless Brogan knows a cleaner way to get the thread position, I'll use your solution.

You could just use two conditional statements and an OR.

@Brogan--can you elaborate? Were you thinking of how SuperJETT did this or some other way?

I've looked everywhere and haven't found any examples of conditional statements triggered by thread position in the thread list...
 
This is what I ended up with in thread_list that puts my ad after the 5th post in a thread listing after the stickied threads. There may be a better way but this works.

Code:
<xen:foreach loop="$threads" value="$thread" i="$i">
<xen:include template="thread_list_item" />
<xen:if is="!{xen:helper ismemberof, $visitor, 26, 4}">
<xen:if is="{$i} == 5">

Dude, you're a genius! Thanks!!!
 
Top Bottom