phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
Google adsense in PHPBB
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB Forum
::  
Author Message
ultimatehandyman
PR2
PR2


Joined: 15 Mar 2007
Posts: 205

Google adsense in PHPBBPosted: Mon Apr 02, 2007 11:29 am    Post subject: Google adsense in PHPBB

Would it be possible to translate the Google adsense mod that is used on this site ( http://www.phpbb-seo.com/forums/le-forum-phpbb/discussions-vt1078.html#11818 ) into English please?

Thanks in advance

chez
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

Google adsense in PHPBBPosted: 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 :

Code:

$add_after = 0;


To output it after the second post instead of the first one, one could use :

Code:

$add_after = 1;


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 Wink

In all this you'll obviously have to replace
Code:
full AdSense code


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
Visit poster's website
ultimatehandyman
PR2
PR2


Joined: 15 Mar 2007
Posts: 205

Google adsense in PHPBBPosted: Sat Apr 21, 2007 12:29 pm    Post subject: Re: Google adsense in PHPBB

Thanks very much for that Wink

I will take a look at this when I have more time next week Very Happy

Thanks again Wink
Back to top
ultimatehandyman
PR2
PR2


Joined: 15 Mar 2007
Posts: 205

Google adsense in PHPBBPosted: 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 Idea

When I was not logged in the mod worked and leaves adsense after the first post and at the end of the topic Wink

This is just what I was looking for Very Happy

Thanks again DCZ Wink
Back to top
spy



Joined: 07 Mar 2007
Posts: 38

Google adsense in PHPBBPosted: 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
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

Google adsense in PHPBBPosted: Tue Apr 24, 2007 9:26 am    Post subject: Re: Google adsense in PHPBB

You're welcome Very Happy

_________________
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
Visit poster's website
aspelsit



Joined: 26 Apr 2007
Posts: 1

Google adsense in PHPBBPosted: 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
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

Google adsense in PHPBBPosted: Fri Apr 27, 2007 4:07 pm    Post subject: Re: Google adsense in PHPBB

And welcome Very Happy

If you only want one level of sub forums, like on phpBB SEO, you could use the simple sub forum mod, it's easier to deal with and will as well allow easier migrating to phpBB3.

About CH, the problem is always the same, it's barely not phpBB anymore, more like a fork.

I'll take a look at it when I'll get more time Wink

++

_________________
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
Visit poster's website
tmhung



Joined: 13 May 2007
Posts: 14

Google adsense in PHPBBPosted: 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
PR2


Joined: 15 Mar 2007
Posts: 205

Google adsense in PHPBBPosted: 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'

Wink
Back to top
tmhung



Joined: 13 May 2007
Posts: 14

Google adsense in PHPBBPosted: 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
PR2


Joined: 15 Mar 2007
Posts: 205

Google adsense in PHPBBPosted: 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 Wink

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
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

Google adsense in PHPBBPosted: Tue May 15, 2007 7:58 am    Post subject: Re: Google adsense in PHPBB

Well, had you noticed the mod would only output adds in public forum for anybody but the admin (user id = 2) ?

Did you try to browse you forum as guest or regular user ?

++

_________________
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
Visit poster's website
tmhung



Joined: 13 May 2007
Posts: 14

Google adsense in PHPBBPosted: 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
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13354

Google adsense in PHPBBPosted: Wed May 16, 2007 8:33 am    Post subject: Re: Google adsense in PHPBB

Then, that's probably because you messed up a bit with the template part.

Check the code changes again, they are few, and about templates, the code change concern subSilver, it should not be very different for other styles but still.

++

_________________
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
Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB Forum
Page 1 of 3 Goto page 1, 2, 3  Next

Navigation Similar Topics

Jump to: