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

XF 1.2 Google ads in thread

Discussion in 'XenForo Questions and Support' started by tommydamic68, Sep 1, 2013.

  1. tommydamic68

    tommydamic68 Well-Known Member

    Is there an ad on that can allow a google ad as 2nd post automatically on each new thread?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Use the ad_message_below template.

    Then use this:
    How can I show content after post x on every page in a thread?
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x AND !{$message.conversation_id}">
    This content will show after post x on every page in a thread
    </xen:if>
     
    CyclingTribe and tommydamic68 like this.
  3. tommydamic68

    tommydamic68 Well-Known Member

    @Brogan I get this error message.

    Screen Shot 2013-09-05 at 5.53.25 AM.png
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Did you change x to a value?
     
  5. tommydamic68

    tommydamic68 Well-Known Member

    Where do i place the google ad code here?

    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x AND !{$message.conversation_id}">
    This content will show after post x on every page in a thread
    </xen:if>
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    Replace the content between the xen:if. However, you need to replace the x in the conditional with a number for it to work. That's what the error message is complaining about.
     
  7. CyclingTribe

    CyclingTribe Well-Known Member

    (y)
     
  8. tommydamic68

    tommydamic68 Well-Known Member

    Ok - got an ad, i don't want it in a post, can it be between first and second post with a border?

    Screen Shot 2013-09-05 at 7.10.22 PM.png
     
  9. Tracy Perry

    Tracy Perry Well-Known Member

  10. tommydamic68

    tommydamic68 Well-Known Member

    ok - i have it, but his code is for guest, how do i make it for all? member, guests etc. Here is what i have so far.

    hook name="ad_message_below" /><xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
    <xen:if is="!{$visitor.user_id}">
    <li class="message">
    <div class="messageUserInfo" itemscope="itemscope"">
    <div class="messageUserBlock">
    <div class="avatarHolder">
    <span class="helper"></span>
    <xen:avatar user="$visitor" size="m" img="true" />
    </div>
    <h3 class="userText">
    <span style="font-weight: bold">Sponsor</span>
    </h3>
    <span class="arrow"><span></span></span>
    </div>
    </div>
    <div class="messageInfo primaryContent">
    <div class="messageContent">
    <article>
    <blockquote class="messageText ugc baseHtml">
    <script type="text/javascript">
    google_ad_client = "ca-pub-id";
    width = document.documentElement.clientWidth;
    /* Message Below Responsive 2 */
    google_ad_slot = "1234567890";
    google_ad_width = 320;
    google_ad_height = 50;
    if (width > 619) {
    /* Message Below Responsive 1 */
    google_ad_slot = "1234567890";
    google_ad_width = 468;
    google_ad_height = 60;
    }
    if (width > 879) {
    /* Message Below */
    google_ad_slot = "1234567890";
    google_ad_width = 728;
    google_ad_height = 90;
    }
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </xen:if>

    </xen:if>
     
  11. tommydamic68

    tommydamic68 Well-Known Member

    Screen Shot 2013-09-05 at 9.04.10 PM.png Also - can you tell me how to wrap my google ad nicely with a border like @Brogan had done is his guest ad?
     
  12. Tracy Perry

    Tracy Perry Well-Known Member

    Remove the <xen:if is="!{$visitor.user_id}"> and the corresponding </xen:if> from the statement.
    The second (more complex) example in his resource should help you out on the guest post type ad.
     
  13. tommydamic68

    tommydamic68 Well-Known Member

    Thanks @Tracy Perry it worked! any idea how to get the border around other ads? so its nestled into the style?
     
  14. Tracy Perry

    Tracy Perry Well-Known Member

    Haven't played with that aspect yet - is something that I'm planning on doing. Maybe @Brogan can give some guidance.
     
  15. Brogan

    Brogan XenForo Moderator Staff Member

    I have limited net access currently and only from a mobile device so can only offer limited support.

    What is it you're trying to do?
     
  16. MattW

    MattW Well-Known Member

    I think they are wanting to style the add like a post
    image.jpg
     
  17. Brogan

    Brogan XenForo Moderator Staff Member

  18. tommydamic68

    tommydamic68 Well-Known Member

    Actually, i want a border to match the site like this around this ad - see the border around the 2nd post ad with the sponsor title (anyway to center that ad?)- like that. I want the border like the 2nd image that i have the black line drawn around.



    Screen Shot 2013-09-06 at 5.18.02 AM.png

    Screen Shot 2013-09-06 at 5.18.15 AM.png
     
  19. tommydamic68

    tommydamic68 Well-Known Member

    Would also like the title for ad like this

    Screen Shot 2013-09-06 at 5.18.02 AM.png
     
  20. RoldanLT

    RoldanLT Well-Known Member

    Don't use such Phrase title for Adsense, or you will be banned.
    You may use "Advertisement" / "Google Adsense" Title.
    Not sponsors :)
     
    CyclingTribe and tommydamic68 like this.

Share This Page