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

Ad after first post - which template?

Discussion in 'XenForo Questions and Support' started by Diablotic, Jun 24, 2011.

  1. Diablotic

    Diablotic Active Member

    Which template should I use to insert my code that would display ad after first message (outside first message) in the way it looks like it is another post.
    I have my code ready but I cannot figure into which template I should insert it to.
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    ad_message_below

    Use this conditional:

    <xen:if is="{$post.position} == 0">
    advert
    </xen:if>
     
    Webby, Jafo, longanh and 1 other person like this.
  3. principia

    principia Well-Known Member

    or you can use the "rotating ads" addon. theres an option for the second post and you need no template edits
     
  4. Diablotic

    Diablotic Active Member

    @Brogan: That was the first conditional I used and it didn't work that's why I started this thread.
    Using this conditional it displays advert in the first post but I do want it to show outside it, just as it is another, standalone post.

    @principia: I do not want to use any addons to do that.
     
  5. Brogan

    Brogan XenForo Moderator Staff Member

    It doesn't display it in the post, the ad_message_body template does that.

    If you want to create more separation however, add this as the first line in the ad template

    </li><li>
     
  6. Diablotic

    Diablotic Active Member

    Yes, had tried that before but also with no luck.

    First picture is for the option without </li><li>
    Second one is what happens after I use </li><li>

    withoutli.jpg
    withli.jpg

    As you can see adding the code into ad_message_body is adding "advert" into first post. I do not want that. I want to have "advert" between first and second post.

    Using XF 1.0, no changes to the default theme.
     
  7. Brogan

    Brogan XenForo Moderator Staff Member

    There must be something wrong with your code, it works fine for me in my testing.
     
  8. Diablotic

    Diablotic Active Member

    When you open ad_message_body, do you have any code in there?
    In mine there is:
    Code:
    <xen:hook name="ad_message_body" />
    .
     
  9. Brogan

    Brogan XenForo Moderator Staff Member

    That's just text explaining which hook is used.

    You can remove that and place whatever code you want in that template.

    As I said though, you need to use the ad_message_below template, not the ad_message_body template.
     
  10. Diablotic

    Diablotic Active Member

    Ha! For some reason for the entire time I was using ad_message_body template! My bad.
     
  11. planetzu

    planetzu Member

    Hey guys, what will I need to edit in the conditional if I want to display this Ad only to non-registered users?

    <xen:if is="{$post.position} == 0">
    advert
    </xen:if>
     
  12. Brogan

    Brogan XenForo Moderator Staff Member

  13. Jens1986

    Jens1986 Active Member

    Why does this code not work?

    ad_message_below:
    Code:
    <xen:comment> PLACE YOUR ADVERTISEMENT CODE DIRECTLY BELOW </xen:comment>
    </li><li><xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <!-- ALOPECI TOPP -->
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="ca-pub-...."
         data-ad-slot="...."
         data-ad-format="auto"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    </xen:if>
    It breaks the design, the posts after post #2 goes to 100% width
     
  14. Brogan

    Brogan XenForo Moderator Staff Member

  15. Jens1986

    Jens1986 Active Member

    I dont want a "fake" user to post the ad, I just want it after the first post, but not inside.


    </li><li> <- this is what breaks the design. Any idea @Brogan ?
     
    Gabby Sama likes this.
  16. Adrian D.

    Adrian D. Member

    Also having issues with <li class="">my adsense code</li> in ad_message_below (right after first post)

    I've successfully added it at the end of all messages and above threads list but somehow adding it in ad_message_below it breaks the design leaving 2nd post showing as empty.
     
  17. Mr Lucky

    Mr Lucky Well-Known Member

    AndyB likes this.
  18. Adrian D.

    Adrian D. Member

    I don't really see a reason to install an addon just for this.

    Also adding a banner without any <li></li> has the exact same result that addon has, my issue starts while adding the <li> tags.
     
  19. Webby

    Webby Member

    Bro it works with going under the first post, only problem is that it looks messed up for me. Any ideas on how this could be resolved or what the cause could be?

    Thanks in advance.

    Screen Shot 2016-02-03 at 8.09.57 PM.png

    I added the code to the ad_message_body to avoid the above issue but now I need the ad to appear underneath the content of the 1st post.

    This is what I have now:

    Screen Shot 2016-02-03 at 8.16.03 PM.png

    The reason why I need it under is because I have an ad in the ad_above_content template so it clutters the page as it is now.
     
    Last edited: Feb 4, 2016
  20. Webby

    Webby Member

    Bro do you know how to make an ad appear after ever 3 posts? I know some java but not PHP. Its so simple to do but I can't. :X3:
     

Share This Page