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

Place ad after last post

Discussion in 'Styling and Customization Questions' started by Jafo, Oct 21, 2014.

  1. Jafo

    Jafo Active Member

    If this has been solved before, then I apologize, but I searched and searched and did not find a great answer to this problem.

    I needed to be able to show an ad after the last post on each page. All the solutions I found would not work if the page did not fill all the slots for a full page. This does:

    <xen:if is="{$message.position} == {$xenOptions.messagesPerPage} - 1 OR {$message.position} == {$thread.reply_count}">
       <!--AD CODE HERE -->
    I just wanted to post this here so others and myself can find it again in the future when needed.
  2. Goodfella

    Goodfella Active Member

  3. Jafo

    Jafo Active Member

    Not really necessary as this code is part of an internal addon we are making for our sites.
  4. dethfire

    dethfire Well-Known Member

    So is there a way to do with via conditionals? I am looking to place an ad in the last post of each page (granted it's not the first or second post)
  5. popowich

    popowich Active Member

    Is there a way with the conditionals to do a placement "if there are 3 or more posts, then place in the last post?"

    edit: edit: nope, my edit was wrong. I still have this question, and settling for a third post placement in the meantime.
    Last edited: Jan 14, 2016
  6. popowich

    popowich Active Member

    I'm trying to piece some of the previous discussions together into a working answer.

    What's the right way to write this?

    <xen:if is="{$post.position} == {$thread.reply_count} AND {$xenOptions.messagesPerPage} > 2">

    I'm looking for the last post on a page only if there are more than 2 posts on that page.
  7. popowich

    popowich Active Member

    $5 paypal to the working answer just to make my day more excellent.

    Using Xenforo conditionals and not a paid add-on, I want to place an ad in the last post of every page only if there are 3 or more posts on the page being viewed.

    If there are 7 posts it goes in post 7, if there are 3 posts it goes in post 3. If it's the first post on the second page, it should not display.
  8. Brogan

    Brogan XenForo Moderator Staff Member

    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == {$xenOptions.messagesPerPage} - 1 OR {$post.position} == {$thread.reply_count} AND {$thread.reply_count} % {$xenOptions.messagesPerPage} > 1">
        Ad code here
    popowich likes this.
  9. popowich

    popowich Active Member


Share This Page