XF 2.0 Having trouble putting an ad after the first post

Sportsoutlaw

Active member
With the new ad system, I am selecting "post: below message content". I can see that, by default, this puts an ad after every post.

Trying to just put the ad either after just the first post, or ideally, after the 1st, 10th, and last post. I had codes that worked in the past, but now I can't seem to get anything to work. Seems no matter what I try, the ad shows up after every post in the thread.

All the codes I used in the past seem to be useless now.
 
You will still need to use conditional statements to only show after post x.

They will need to be rewritten for XF2 as the syntax has changed.

Thanks.

If anybody has done this already and willing to share, that would be greatly appreciated. I like having the ad in a couple of the posts, but definitely don't want them in every post.
 
If you post the code you used previously I'll convert it for you.

Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
adcode here
</xen:if>
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 1">
adcode here
</xen:if>
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == {$xenOptions.messagesPerPage} - 1 OR {$post.position} == {$thread.reply_count} AND {$thread.reply_count} % {$xenOptions.messagesPerPage} > 1">
adcode here
</xen:if>

The above one puts an ad into whatever the last post is.

Below is a more simpler code for three ads

Code:
<xen:if is="!{$visitor.user_id}">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 1">
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 19">
</xen:if>
</xen:if>

These are the two I have been using for a while.
 
It's not a whole lot of difference:
HTML:
<xf:if is="$post.position % $xf.options.messagesPerPage == 0">
    <div style="text-align: center; padding: 10px;">
        <img src="https://storage.googleapis.com/support-kms-prod/SNP_501E7C3D5CA3CA07C641E6BAFB8A53C794CF_2922339_en_v2" />
    </div>
</xf:if>

<xf:if is="$post.position % $xf.options.messagesPerPage == 1">
    <div style="text-align: center; padding: 10px;">
        <img src="https://storage.googleapis.com/support-kms-prod/SNP_501E7C3D5CA3CA07C641E6BAFB8A53C794CF_2922339_en_v2" />
    </div>
</xf:if>

<xf:if is="$post.position % $xf.options.messagesPerPage == 19">
    <div style="text-align: center; padding: 10px;">
        <img src="https://storage.googleapis.com/support-kms-prod/SNP_501E7C3D5CA3CA07C641E6BAFB8A53C794CF_2922339_en_v2" />
    </div>
</xf:if>

Result:
1506269117430.webp
The main differences are:
  • You don't need the user_id check, as there are checkboxes on the edit advertising page to show/hide the advert based on user groups (if you did, then the correct syntax would be $xf.visitor.user_id.
  • <xen: has become <xf:.
  • $xenOptions and some other "global" template params (like visitor) are now in the $xf namepace, e.g. $xf.options.
  • In some contexts, such as the conditions, you no longer need the curly braces.
Obviously the styling was thrown together, you might want to do something different.
 
It's not a whole lot of difference:
HTML:
<xf:if is="$post.position % $xf.options.messagesPerPage == 0">
    <div style="text-align: center; padding: 10px;">
        <img src="https://storage.googleapis.com/support-kms-prod/SNP_501E7C3D5CA3CA07C641E6BAFB8A53C794CF_2922339_en_v2" />
    </div>
</xf:if>

<xf:if is="$post.position % $xf.options.messagesPerPage == 1">
    <div style="text-align: center; padding: 10px;">
        <img src="https://storage.googleapis.com/support-kms-prod/SNP_501E7C3D5CA3CA07C641E6BAFB8A53C794CF_2922339_en_v2" />
    </div>
</xf:if>

<xf:if is="$post.position % $xf.options.messagesPerPage == 19">
    <div style="text-align: center; padding: 10px;">
        <img src="https://storage.googleapis.com/support-kms-prod/SNP_501E7C3D5CA3CA07C641E6BAFB8A53C794CF_2922339_en_v2" />
    </div>
</xf:if>

Result:
View attachment 158561
The main differences are:
  • You don't need the user_id check, as there are checkboxes on the edit advertising page to show/hide the advert based on user groups (if you did, then the correct syntax would be $xf.visitor.user_id.
  • <xen: has become <xf:.
  • $xenOptions and some other "global" template params (like visitor) are now in the $xf namepace, e.g. $xf.options.
  • In some contexts, such as the conditions, you no longer need the curly braces.
Obviously the styling was thrown together, you might want to do something different.
Is it possible to adopt this modification for guests only? We want to show ads only to guests, not registered members.

Thank you.
 
Top Bottom