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

XF 1.4 How to restrict adsense code to certain section?

Discussion in 'Styling and Customization Questions' started by garry420, Feb 27, 2015.

  1. garry420

    garry420 Active Member

    I have few questions which i need for my forum

    How to restrict adsense code to certain section of forum ?
    Reason: I will add news to this section.

    I want my ads to show up just 3 times in thread but everytime someone comments it starts showing up .
    someone please guide me which is the best place to post adsense code in and how to do it ?

    regards
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

  3. garry420

    garry420 Active Member

  4. Tracy Perry

    Tracy Perry Well-Known Member

    So do I.. but that guide is easy enough to understand.
    And what do you mean "show up 3 times in thread"? Do you mean after the first post, then the second post and finally the third post? You need to be more precise in what you are asking about.
    I use the ad_message_below template myself.

    You could probably use the
    Code:
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x">
    This content will show after post x on every page
    </xen:if>
    code. If wanting it after set posts, then use this instead of a single number (which is what the x represents) replace it with an array.

    Code:
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == array(y, z)">
    This content will show after post y and z on every page
    </xen:if>
    where y,z are the post numbers. You can do additional by just using x,y,z format.

    Now, if you are wanting it to only show in once specific forum this will probably work


    Code:
    <xen:if is="{$forum.node_id} == x">
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == array(y, z)">
    This content will show after post y and z on every page
    </xen:if>
    </xen:if>
    
    Where X is the actual forum node ID number.

    The only problem is, if you use ad_message_below then you will only be showing the ads on that one forum, unless you do additional if/then statements.
     
    Last edited: Feb 27, 2015
  5. garry420

    garry420 Active Member

    I mean every-time someone replies or ads comment, one ad starts showing with theta added reply/comment.
     
  6. Tracy Perry

    Tracy Perry Well-Known Member

    ad_below_message will add an ad below every post (not conversation)... but doing it below every post will - if you are using adsense - quickly put you in violation of their TOS.
    You could do it after the 2nd, 5th and 8th post or something similar.

    I've given you an example above to try. Without knowing more (exact) details of the node ID # and what posts you want it after exactly then further help is going to be limited.
     
    Last edited: Mar 1, 2015
    garry420 likes this.
  7. garry420

    garry420 Active Member

    I m confused..hence i am planning to create a widget at side bar. but i dono how to do that. can you guide me ?
    i mean widget in sidebar where in i can put adsense code
    you can check my forum from my signature, and please guide me to do better..:)
     
  8. Tracy Perry

    Tracy Perry Well-Known Member

    There are templates in the ACP -> Appearance -> Templates that allow you to control where ads are placed using the default sidebar. If you are using BD Widgets, then you will need to use one that renders one of the ad-templates for you or create your own template.

    Screen Shot 2015-03-01 at 9.32.56 AM.png

    In your original posts you were wanting ads in the posts/comments area, now you are talking about the sidebar.
    The only way I know to "guide you better" is to actually do it. I've given you template examples that you can modify to work for you in the posts.
    The sidebar will be similar -but depends on whether you are using BD Widgets or the built in stuff. Another option may be @Audentio Design new Ad Manager.
     
    garry420 likes this.
  9. garry420

    garry420 Active Member

    what if i want to place adsense code within certain content in forum post , is that possible ?
    If yes how if no what should i do to get bit more revenue ?
     
  10. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, it's possible using conditional statements.
     
  11. garry420

    garry420 Active Member

    how can u give me exact code ? and where i have to replace it ?
     
  12. Brogan

    Brogan XenForo Moderator Staff Member

    There are guides in my signature for conditional statements and AdSense.

    The exact code required will depend on where and how you want to place it.
     
    garry420 likes this.

Share This Page