XF 2.2 Ads between threads in forum view

Bozza

Member
I've been slowly configuring my shiny new 10m+ post Xenforo forum after a migration from vBulletin and I feel like I'm getting there.

I've managed to configure ads pretty easily, but one use case I had on vB that I can't seem to replicate yet is to add banner ads between selected thread titles on the forum view.

In case I'm using the wrong terminology, I mean where the arrow is in the attached screenshot.

I'd probably want to be able to insert a banner between threads 10 and 11, between 25 and 26, and between 40 and 41.

Any advice on how I may do this would be very much appreciated!

Screenshot 2022-10-26 at 01.11.48.webp
 
Have a look at Ads Manager by siropu addon

 
Conditional statements can be used with this ad position:

1666793815716.png

This will show ads below the post IDs in the array:
HTML:
<xf:if is="in_array($post.position, [10, 25, 40])">
  Ad content
</xf:if>

This will show ads after every 10th post:
HTML:
<xf:if is="$post.position % $xf.options.messagesPerPage == 10 AND $post.message_state == 'visible'">
    Ad Content
</xf:if>
 
Conditional statements can be used with this ad position:

View attachment 275545

This will show ads below the post IDs in the array:
HTML:
<xf:if is="in_array($post.position, [10, 25, 40])">
  Ad content
</xf:if>

This will show ads after every 10th post:
HTML:
<xf:if is="$post.position % $xf.options.messagesPerPage == 10 AND $post.message_state == 'visible'">
    Ad Content
</xf:if>
Thanks - from a search on here, I'd already managed to find something similar for ads between posts in thread view, and it's working very well.

My request here is for between threads (not posts) in the forum view.
 
Have a look at Ads Manager by siropu addon


Thanks - I had seen that, but wasn't sure if the specific positioning I was wanting was catered for with that add-on. I'm happy to pay for the add-on if there are no possible conditional workarounds, and the add-on does handle that exact ad position.
 
Yes, I just realised you meant the forum view, not thread view.

I would have to check but I don't believe there's a sequential param for the thread list.
 
Yes, I just realised you meant the forum view, not thread view.

I would have to check but I don't believe there's a sequential param for the thread list.
Thanks - I couldn't find anything from some quite extensive searching.

All my other ad requirements have been met by a combination of the built-in advertising system and using widgets to house ad units, so this is the last piece of my personal ad jigsaw.

The thread list accounts for around a third of the site's traffic so two/three banners arranged down the page can make a good contribution to financially supporting the site.
 
Thanks - I had seen that, but wasn't sure if the specific positioning I was wanting was catered for with that add-on. I'm happy to pay for the add-on if there are no possible conditional workarounds, and the add-on does handle that exact ad position.

With Siropu's addon, it has these default positions set for the thread list area. I think you could use 'below (or above) thread list item where X is position in the list, which you could set for each banner space you wanted to use. I didn't have time to try a mockup, just wanted to show the forum view positions where the thread position markers are.

1666798257065.png

Edit: I did a quick mockup from one of my installs using @Siropu's ad manager (just used 10,11 as you mentioned in your original post)

1666798893468.png
 
Last edited:
I found something a long time ago somewhere here, and are using it like this with:
Code:
<xf:foreach loop="$threads" value="$thread" i="$i">
and
Code:
<xf:if is="{$i} == 1">
    <div class="structItem">
        <xf:ad position="forum_view_below_stickies" arg-forum="{$forum}" />
    </div>
</xf:if>
in forum_view
and some other templates that I wanted banners in.
 
I think I got the idea from:
Where @Brogan gave a very similar answer nine years ago as in this thread :)

Maybe there is something about it somewhere in:

Taking some time to search for info and try to learn and test it out on a local copy of your site is a good way to get what one wants.

Maybe someone else with more knowledge have a better solution and/or can better explain how to do it.
 
Bumping this thread, as I'm trying to do something similar. I've modified the forum_view thread loop (capturing the loop variable i to use in the conditional, then adding a conditional on i). Is there a way to get the added content to "look" like another thread (separators, etc.)?
 
Last edited:
Did you all figure out a solution for this? I'd like to be able to place an ad between threads in a forum. Hard to monetize those forum view views. Thanks
 
Did you all figure out a solution for this? I'd like to be able to place an ad between threads in a forum. Hard to monetize those forum view views. Thanks
Yeah.

It was a while ago now, but it looks like I got some of the code from this thread and possibly some from the help with conditionals.

Anyway, in my forum_view template I have this from line 147. Some of it may have already been in the original, whilst some I definitely added. It gives me four ad banners equidistant down the thread listing.

<div class="structItemContainer-group js-threadList">
<xf:if is="$threads is not empty">
<xf:foreach loop="$threads" value="$thread" i="$i">
<xf:macro name="{{ $templateOverrides.thread_list_macro ?: 'thread_list_macros::item' }}"
arg-thread="{$thread}"
arg-forum="{$forum}"
args="{$templateOverrides.thread_list_macro_args}" />

<xf:if is="{{$xf.visitor.isMemberOf([25])}}">

<xf:else />

<xf:if is="in_array({$i}, [10])">

<div style="margin:10px auto 10px auto; text-align:center; width:100%; overflow:hidden; min-height: 90px;">
<div id="advert1"></div>
</div>

</xf:if>

<xf:if is="in_array({$i}, [21])">
<div style="margin:10px auto 10px auto; text-align:center; width:100%; overflow:hidden; min-height: 90px;">
<div id="advert2"></div>
</div>
</xf:if>

<xf:if is="in_array({$i}, [32])">
<div style="margin:10px auto 10px auto; text-align:center; width:100%; overflow:hidden; min-height: 90px;">
<div id="advert3"></div>
</div>
</xf:if>
<xf:if is="in_array({$i}, [43])">
<div style="margin:10px auto 10px auto; text-align:center; width:100%; overflow:hidden; min-height: 90px;">
<div id="advert4"></div>
</div>
</xf:if>

</xf:if>
 
Back
Top Bottom