Page 1 of 2

Adding Google AdSense after first post

Posted: Mon Sep 01, 2008 7:24 pm
by MCC08
Hello, I need some help with this and hoping someone can give me some guidance since the file structure of viewtopic.php has changed in phpbb3. In phpbb2 I create a real SIMPLE mod that placed a duplicate post that posted a Google adsense block and it looked like Google posted it after the first post. See screen shot blow for example. It was real easy to install just once snippet of code to add and you were done. Real sleek and nice and VERY effective. What I am needing to know is where in veiwtopic.php I can place this code. In phpbb2 it was placed after the postrow was created. I can not find where this ends in phpbb3. I am going to need to update the variables for phpbb3 which isn't a big deal. I am just not sure where in that file I need to add this updated code. Below is the code sample for phpbb2 that I used to create this. So can anyone give me some suggestions and guidance on this?

-Thanks

Code: Select all

#
#-----[ FIND ]------------------------------------------
#
      'U_POST_ID' => $postrow[$i]['post_id'])
   );

#
#-----[ AFTER, ADD ]------------------------------------------
#
   if($i == $ad_after)
   {
      $row_color = ( !($num % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
      $row_class = ( !($num % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
      $num ++;

       $mini_post_url = append_sid('viewtopic.' . $phpEx . '?' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#ad'; 
      $template->assign_block_vars('postrow', array(
         'ROW_COLOR' => '#' . $row_color,
         'ROW_CLASS' => $row_class,
         'POST_DATE' => $post_date,
         'POST_SUBJECT' => 'Advertisement',
         'MINI_POST_IMG' => $mini_post_img,
         'POSTER_NAME' => 'Google',
         'POSTER_RANK' => 'Sponsor',
         'POSTER_AVATAR' => '<img src="images/google_avatar.gif" alt=""/>',
         'MESSAGE' => '<div align="center">YOUR ADSENSE CODE HERE</div>',
         'L_MINI_POST_ALT' => $mini_post_alt,
         'U_MINI_POST' => $mini_post_url,
         'U_POST_ID' => 'ad')
      );
   }

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM ?>
Image

Re: Adding Google AdSense after first post

Posted: Mon Sep 01, 2008 11:03 pm
by ಠ_ಠ
EDIT: styles/*STYLE*/template/viewtopic_body.html

Find

Code: Select all

<!-- END postrow -->
Add before

Code: Select all

<!-- IF postrow.S_FIRST_ROW == 2 -->
Enter the code of what you want to appear after the first post here.
<!-- ENDIF -->

Re: Adding Google AdSense after first post

Posted: Mon Sep 01, 2008 11:40 pm
by MCC08
Thanks for the suggestion but that is not what I am looking for or referring to. This code is added to the viewtopic.php which creates a new row after a post is create that looks like Google posted it. Look at the screenshot and the code in my first post to see what I am talking about.

So what I am needing to know is where in the viewtopic does the postrow end so I can try to clone a row with the google code like I did in phpbb2. The template files you can not add php to it so your suggestion will not work, but thanks.

Any other help?

Re: Adding Google AdSense after first post

Posted: Tue Sep 02, 2008 6:07 am
by david63
MCC08 wrote:The template files you can not add php to it
You can have php in your template file see http://startrekguide.com/community/view ... =50&t=1325. The ability to use php in template files was put in for this very type of situation.

Re: Adding Google AdSense after first post

Posted: Tue Sep 02, 2008 4:05 pm
by MCC08
So this will allow me to include php in pages with html extensions? Very cool!

Unfortunately that is not what I am needing. I mean I guess I can create a separate page maybe with the post row variables to clone just for that Google post and call it with the php include. Sounds like the easier way even though it might be more work. I don't know if those variables will be parsed though out side the viewtopic.php?

Re: Adding Google AdSense after first post

Posted: Tue Sep 02, 2008 5:41 pm
by david63
You can either include a .php file or you can enter php code in the template - what more do you need?
MCC08 wrote:So this will allow me to include php in pages with html extensions? Very cool!

Unfortunately that is not what I am needing.
seems to contradict
MCC08 wrote:The template files you can not add php to it so your suggestion will not work, but thanks.

Re: Adding Google AdSense after first post

Posted: Wed Sep 03, 2008 12:51 am
by MCC08
Whoa killer calm down. I think I made it fairly clear in my first post what I was trying to do. If you don't understand that then I am sorry. Maybe you should go back and read it and analyze what I posted and trying to do.

You are also quoting me on a statement you believe to be in contradiction I made before I knew you could add php in phpbb? How much sense does that make? :roll:

Anyways, I am good, I found another solution in the mods that seems to work better since cloning a post takes up more room in phpbb3 then in phpbb2.

-Thanks

Re: Adding Google AdSense after first post

Posted: Thu Jul 09, 2009 3:19 am
by Artemis Artium
I would also appreciate some help with this. Could you let me know how you solved your issue? I know exactly what you were wanting to accomplish and I am having the same problems getting it to work.

Thanks in advance.

Re: Adding Google AdSense after first post

Posted: Sat Aug 22, 2009 10:02 am
by Nawid
no update? I'm also interested in this....

Re: Adding Google AdSense after first post

Posted: Fri Oct 16, 2009 5:55 pm
by Joseppi
I really hate it when someone finds a solution to a problem that they posted a question to and don't bother to share it with the rest of us.

Re: Adding Google AdSense after first post

Posted: Sat Oct 17, 2009 11:21 am
by stickerboy
I followed the code posted in this KB article: http://www.phpbb.com/kb/article/adverti ... in-phpbb3/
Look at the "Ads before or after the first post in a topic" section ;)

Re: Adding Google AdSense after first post

Posted: Thu Nov 12, 2009 7:18 pm
by motzned
OPEN viewtopic.php

SEARCH

Code: Select all

'L_IGNORE_POST'		=> ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&p={$row['post_id']}&view=show#p{$row['post_id']}" . '">', '</a>') : '',
	);
ADD AFTER

Code: Select all

if($i == 1)
{
  $adbox_content = 'YOUR ADCODE HERE';
  $postrow_ads = array(
		'POST_AUTHOR_FULL'		=> $user->lang['ADVERTISING'],
    'POST_AUTHOR'			=> $user->lang['ADVERTISING'],	
		'POST_DATE'			=> $user->format_date($row['post_time'], false, ($view == 'print') ? true : false),
		'MESSAGE'			=> $adbox_content,
	);
	
	$template->assign_block_vars('postrow', $postrow_ads);  	
}
replace YOUR ADCODE HERE with your adcode or put your adcode in a file called postrow_ads.txt
and copy it to your root folder.
then use:

Code: Select all

$adbox_content = file_get_contents($phpbb_root_path . 'postrow_ads.txt');
OPEN common.php in your language directory and add:

Code: Select all

'ADVERTISING' => 'Advertising',

Re: Adding Google AdSense after first post

Posted: Mon Dec 07, 2009 3:07 am
by jinkazama75
is it possible to add an avatar to ad user?

Re: Adding Google AdSense after first post

Posted: Thu Dec 02, 2010 8:05 pm
by CrazyDave
i tried using both codes provided on my subsilver2 themed style, and neither worked.

i am also interested in finding a solution to this as i want my ads to blend in with the other posts and make it look like google posted after the 1st post of the topic :?

Re: Adding Google AdSense after first post

Posted: Sun Jan 30, 2011 12:40 pm
by martn
motzned wrote:OPEN viewtopic.php

SEARCH

Code: Select all

'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&p={$row['post_id']}&view=show#p{$row['post_id']}" . '">', '</a>') : '',
);
ADD AFTER

Code: Select all

if($i == 1)
{
$adbox_content = 'YOUR ADCODE HERE';
$postrow_ads = array(
'POST_AUTHOR_FULL' => $user->lang['ADVERTISING'],
'POST_AUTHOR' => $user->lang['ADVERTISING'], 
'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false),
'MESSAGE' => $adbox_content,
);

$template->assign_block_vars('postrow', $postrow_ads); 
}
replace YOUR ADCODE HERE with your adcode or put your adcode in a file called postrow_ads.txt
and copy it to your root folder.
then use:

Code: Select all

$adbox_content = file_get_contents($phpbb_root_path . 'postrow_ads.txt');
OPEN common.php in your language directory and add:

Code: Select all

'ADVERTISING' => 'Advertising',
Thanks for that! worked perfectly.

I have registeed a new user "Google" who is a sponsor and wondering if there is any way of changing the above code to be posted by particular user_id?? We could then have rank and the avatar shown

Cheers