| :: |
| Author |
Message |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 205
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
Posted: Thu Apr 19, 2007 9:50 am Post subject: Re: Google adsense in PHPBB |
|
|
All right, so here is the code used on phpBB SEO :
The principle is the following, I am assuming that the best is to only output AdSense for public content, but it's not necessarily the best solution, for example if you run an 100% private forum.
But for forum being mostly public, I do think that the fact the Google AdSense bot can actually browse all pages with adds will help out them to be better targeted.
So it goes like this, open viewtopc.php and find :
| Code: |
//
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//
for($i = 0; $i < $total_posts; $i++) |
Add before :
| Code: | // Google AdSense mod www.phpbb-seo.com
$add_add = ( $userdata['user_id'] != 2 && $forum_topic_data['auth_view'] == 0 ) ? TRUE : FALSE;
$add_switch = (( floor( $start / intval($board_config['posts_per_page']) ) + 1 ) < ceil( $total_replies / intval($board_config['posts_per_page'])) )? TRUE : FALSE;
$add_after = 0;
if ( $add_add ) {
$adsence_code = 'full adsense code';
}
// Google AdSense mod www.phpbb-seo.com |
Find :
| Code: | 'U_POST_ID' => $postrow[$i]['post_id'])
); |
After add :
| Code: | // Google AdSense mod www.phpbb-seo.com
if ( $add_add && $i == $add_after ) {
$template->assign_block_vars('postrow.adsence', array(
'ADSENCE_CODE' => $adsence_code)
);
}
// Google AdSense mod www.phpbb-seo.com |
Find :
| Code: |
$template->pparse('body'); |
Before add :
| Code: |
// Google AdSense mod dcz
if ( $add_add && $add_switch ) {
$template->assign_block_vars('adsence', array(
'ADSENCE_CODE' => $adsence_code)
);
}
// Google AdSense mod dcz |
Open viewtopic_body.tpl and find (this for subSilver):
| Code: | | <!-- END postrow --> |
Replace with :
| Code: |
<!-- BEGIN adsence -->
<tr>
<td width="100%" align="center" valign="top" class="row1" colspan="2">{postrow.adsence.ADSENCE_CODE}</td>
</tr>
<tr>
<td class="spaceRow" colspan="2" height="1"><img src="templates/subSilver/images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<!-- END adsence -->
<!-- END postrow -->
<!-- BEGIN adsence -->
<tr>
<td width="100%" align="center" valign="top" class="row1" colspan="2">{adsence.ADSENCE_CODE}</td>
</tr>
<!-- END adsence --> |
Comments :
As is, this mod will output an AdSense after the first post, and one more at the bottom of the topic page in case there is another page in the topic.
Playing with options :
| Code: |
$add_add = ( $userdata['user_id'] != 2 && $forum_topic_data['auth_view'] == 0 ) ? TRUE : FALSE; |
This line defines the overall condition to output adds :
| Code: | | $userdata['user_id'] != 2 && |
This part prevent adds to be outputted for the user id n°2, (usually the founder), so you can, and should, change this to your personal ID.
It is as well possible to prevent adds output fro all admin at once :
| Code: |
$add_add = ( $userdata['user_level'] != ADMIN && $forum_topic_data['auth_view'] == 0 ) ? TRUE : FALSE; |
Or even moderators :
| Code: |
$add_add = ( $userdata['user_level'] != ADMIN && $userdata['user_level'] != MOD && $forum_topic_data['auth_view'] == 0 ) ? TRUE : FALSE; |
Or even all logged users :
| Code: |
$add_add = ( !$userdata['session_logged_in'] && $forum_topic_data['auth_view'] == 0 ) ? TRUE : FALSE; |
For the second adsense :
| Code: | | $add_switch = (( floor( $start / intval($board_config['posts_per_page']) ) + 1 ) < ceil( $total_replies / intval($board_config['posts_per_page'])) )? TRUE : FALSE; |
Here, we check if there is another page in this topic and decide to output the AdSense.
We could for example only check that this topic page has more than n post in it before we add a second ad sense :
| Code: | | $add_switch = (count($total_posts) >= 10 )? TRUE : FALSE; |
First add position :
To output it after the second post instead of the first one, one could use :
One could even use something like :
| Code: |
$add_after = ( count($total_posts) >= 5 ) ? intval( rand (0, ( count($total_posts) - 3 ) ) ) : 0; |
To output the first AdSense at a random position between the first and the 4th post tail
In all this you'll obviously have to replace
With your real AdSense add code.
This code does not output any alternative adds, will leave the code 100% untouched in case no add is outputted (private forum or admin for example).
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 205
|
Posted: Sat Apr 21, 2007 12:29 pm Post subject: Re: Google adsense in PHPBB |
|
|
Thanks very much for that
I will take a look at this when I have more time next week
Thanks again  |
|
|
| Back to top |
|
 |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 205
|
Posted: Mon Apr 23, 2007 4:02 pm Post subject: Re: Google adsense in PHPBB |
|
|
I just tried installing this mod and it did not seem to work and so I installed it again and it dawned on me that it is designed so that the Admin cannot see the ads when logged in
When I was not logged in the mod worked and leaves adsense after the first post and at the end of the topic
This is just what I was looking for
Thanks again DCZ  |
|
|
| Back to top |
|
 |
spy
Joined: 07 Mar 2007 Posts: 38
|
Posted: Mon Apr 23, 2007 10:20 pm Post subject: Re: Google adsense in PHPBB |
|
|
| thanks dcz I'll use it in my forum |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
aspelsit
Joined: 26 Apr 2007 Posts: 1
|
Posted: Thu Apr 26, 2007 6:48 pm Post subject: Google adsense in phpbb with Subcategories |
|
|
| I tried to use your Google Adsense mod but i failed since I could not get the codes to change in viewtopic.php since I had upgraded my phpbb to Categories hierarchy v2.1. My question is how can I Use this mod in Categories hierarchy v2.1 forum since Iwant my forum to have subcategories and subforums or Is there any other way of using the google adsense mod and still add subcategories and subforums without using Categories hierarchy v2.1 forum Please any one Help coz ineed both sucategories and adsense!! |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
tmhung
Joined: 13 May 2007 Posts: 14
|
Posted: Mon May 14, 2007 8:53 am Post subject: Re: Google adsense in PHPBB |
|
|
| where i can insert my ad code into this mod . Please help me |
|
|
| Back to top |
|
 |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 205
|
Posted: Mon May 14, 2007 9:18 am Post subject: Re: Google adsense in PHPBB |
|
|
You put your adsense code in this section that is in the viewtopic.php-
| Code: | // Google AdSense mod www.phpbb-seo.com
$add_add = ( $userdata['user_id'] != 2 && $forum_topic_data['auth_view'] == 0 ) ? TRUE : FALSE;
$add_switch = (( floor( $start / intval($board_config['posts_per_page']) ) + 1 ) < ceil( $total_replies / intval($board_config['posts_per_page'])) )? TRUE : FALSE;
$add_after = 0;
if ( $add_add ) {
$adsence_code = 'full adsense code';
}
// Google AdSense mod www.phpbb-seo.com |
Put your adsense code in between the quotes where it says 'full adsense code'
 |
|
|
| Back to top |
|
 |
tmhung
Joined: 13 May 2007 Posts: 14
|
Posted: Mon May 14, 2007 12:24 pm Post subject: Re: Google adsense in PHPBB |
|
|
| i did like you , but it don't work T_T |
|
|
| Back to top |
|
 |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 205
|
Posted: Mon May 14, 2007 12:47 pm Post subject: Re: Google adsense in PHPBB |
|
|
If you edit the files as suggested by dcz above the mod will work
Trust me, I am no expert and it worked for me.
When the mod is installed you must log out of the forum or you will not see the ads!
The adsense ads do not show up for the site admin by default.
It can be changed though as dcz has described in his post.
I have mine set so that non logged in users can see the ads. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
tmhung
Joined: 13 May 2007 Posts: 14
|
Posted: Wed May 16, 2007 3:19 am Post subject: Re: Google adsense in PHPBB |
|
|
| i saw it but it on the top of page , don't after first post T_T |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
|
|