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

Place Banner in every last post?!

Discussion in 'XenForo Questions and Support' started by DerTobi75, May 2, 2011.

  1. DerTobi75

    DerTobi75 Active Member

    Hi,

    I would like to place a bannerad in every last post on every page, not thread, is there a template conditional for this?

    Regards,

    Tobi
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Add this to the ad_message_body template:

    Code:
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 19">
    Advert code
    </xen:if>
    Change the 19 to whatever number of posts you have per page, minus 1; so if you have 20, set it to 19.
     
  3. DerTobi75

    DerTobi75 Active Member

    I just tried that kind, it kinda works, but what if the thread just have 2 postings?!
     
  4. Enigma

    Enigma Well-Known Member

    Code:
    <xen:if is="{$post.post_id} == {$lastPost.post_id}">
    There's also $post.position_on_page which would simplify the above condition:

    Code:
    <xen:if is="{$post.position_on_page} == {$xenOptions.messagesPerPage}">
    But that only works for pages that have the maximum number of posts on them.
     
    Walter and DerTobi75 like this.
  5. Lawrence

    Lawrence Well-Known Member

    This bit of code will display an ad on the last post of each page: If the last (or only) page contains less posts than the messages per page setting, the last post will still display the ad.

    Code:
    <xen:if is="{$post.position} + 1 == {$xenOptions.messagesPerPage} * {$page}">
        your ad code
    <xen:else />
        <xen:if is="{$post.position} == {$totalPosts} - 1">
            your ad code
        </xen:if>
    </xen:if>
     
    Marcus, Jake Bunce and DerTobi75 like this.
  6. DerTobi75

    DerTobi75 Active Member

    Yes, this is working like a charm! Many thanks, ...
     

Share This Page