1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Ad on first and last post of every page - but if 0 replies, 2 ads appear on same post!

Discussion in 'Troubleshooting and Problems' started by Mike Fara, Aug 4, 2013.

  1. Mike Fara

    Mike Fara Member

    This code works great, however:

    Code:
    <xen:hook name="ad_message_body" />
    <xen:if is="!{xen:helper ismemberof, $visitor, 312}">
    <xen:if is="({$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$message.conversation_id})">
    <div style="float: right;">
    AD_CODE
    </div>
    </xen:if>
    <xen:if is="({$post.position} % {$xenOptions.messagesPerPage} == {$xenOptions.messagesPerPage} - 1 OR {$post.position} == {$thread.reply_count} AND !{$message.conversation_id})">
    <div style="float: right;">
    AD_CODE
    </div>
    </xen:if>
    </xen:if>
    
    When there are no replies, two block ads appear instead of one. Basically I am floating two ads on the first post and last post of each thread page. It is working, except when theres zero replies. In that case, TWO ads get placed in the same post.

    Does anyone have a solution on how one would solve this one? TY
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Consider using AND {$thread.reply_count} > 0 in one of the conditionals.
     
  3. Mike Fara

    Mike Fara Member

    One answer was found here:
    Code:
    
    <xen:hook name="ad_message_body" />
    <xen:if is="!{xen:helper ismemberof, $visitor, 312}">
    <xen:if is="({$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$message.conversation_id})">
    <div style="float: right;">
    AD_CODE
    </div>
    </xen:if>
    
    <xen:if is="(!{$post.position} % {$xenOptions.messagesPerPage} == 0)">
    <xen:if is="({$post.position} % {$xenOptions.messagesPerPage} == {$xenOptions.messagesPerPage} - 1 OR {$post.position} == {$thread.reply_count} AND !{$message.conversation_id})">
    <div style="float: right;">
    AD_CODE
    </div>
    
    </xen:if>
    </xen:if>
    </xen:if>
    
     
    brattanek and jauburn like this.
  4. jauburn

    jauburn Well-Known Member

    Thank you! Exactly what I was looking for.
     
  5. Would somebody mind explaining what the following data represents?:

    {xen:helper ismemberof, $visitor, 312}

    helper? is member of (what)? visitor (guest?) 312?
     
  6. Mike

    Mike XenForo Developer Staff Member

    Is the person viewing the page (the visitor) a member of the user group with ID 312.
     
  7. I see. So in this command:
    <xen:if is="!{xen:helper ismemberof, $visitor, 312}">

    So the ad code associated with that command will not display for anyone in user group 312. Correct?
     
  8. Mike

    Mike XenForo Developer Staff Member

    Correct (it will display for anyone not in group 312).
     
    Sal Collaziano likes this.

Share This Page