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.png
 

Mr Lucky

Well-known member
Have a look at Ads Manager by siropu addon

 

Brogan

XenForo moderator
Staff member
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>
 

Bozza

Member
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.
 

Bozza

Member
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.
 

Brogan

XenForo moderator
Staff member
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.
 

Bozza

Member
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.
 

ENF

Well-known member
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:

ge66

Well-known member
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.
 

ge66

Well-known member
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.
 

ier45

Member
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:
Top