Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Hardcode Adsense code into post #1 and post #3
terrymason Offline
Junior Member
**
Posts: 1
Joined: Dec 2011
Post: #5
RE: Hardcode Adsense code into post #1 and post #3
This will display an ad on every 3rd post.  I believe that google will only let you show 3 ads (or link units) per page, and will just not show more ads after that.  The modulus operator gives the remainder of the division, so $postcounter % 2 is the amount left over when dividing by 2

Code:
1
2
3
4
5
6
7
<if $postcounter %2 == 0 then>
<tr><div align="center">

<!--adsense code-->

</div></tr>
</if>




I personally don't like showing too many ads to members, so use the code below.  It says that if the user is an admin or a guest then show them the ads

Code:
1
2
3
4
5
6
7
8
9
<if $postcounter %2 == 0 then>
<if $mybb->user['usergroup'] == '1' OR $mybb->user['usergroup'] == '4' then>
<tr><div align="center">

<!--adsense code-->

</div></tr>
</if>
</if>

(This post was last modified: 12-01-2011 05:33 AM by terrymason.)
12-01-2011 05:32 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
RE: Hardcode Adsense code into post #1 and post #3 - terrymason - 12-01-2011 05:32 AM

 Standard Tools
Forum Jump: