Adding Google AdSense after first post

Discussion forum for MOD Writers regarding MOD Development.
MCC08
Registered User
Posts: 57
Joined: Sun Aug 31, 2008 7:58 pm

Adding Google AdSense after first post

Post by MCC08 » Mon Sep 01, 2008 7:24 pm

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

User avatar
ಠ_ಠ
Registered User
Posts: 49
Joined: Sun Aug 24, 2008 10:01 pm

Re: Adding Google AdSense after first post

Post by ಠ_ಠ » Mon Sep 01, 2008 11:03 pm

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 -->
┌┐
ಠ_ಠ Serious business.

MCC08
Registered User
Posts: 57
Joined: Sun Aug 31, 2008 7:58 pm

Re: Adding Google AdSense after first post

Post by MCC08 » Mon Sep 01, 2008 11:40 pm

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?

User avatar
david63
Registered User
Posts: 16407
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Adding Google AdSense after first post

Post by david63 » Tue Sep 02, 2008 6:07 am

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.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

MCC08
Registered User
Posts: 57
Joined: Sun Aug 31, 2008 7:58 pm

Re: Adding Google AdSense after first post

Post by MCC08 » Tue Sep 02, 2008 4:05 pm

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?

User avatar
david63
Registered User
Posts: 16407
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Adding Google AdSense after first post

Post by david63 » Tue Sep 02, 2008 5:41 pm

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.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

MCC08
Registered User
Posts: 57
Joined: Sun Aug 31, 2008 7:58 pm

Re: Adding Google AdSense after first post

Post by MCC08 » Wed Sep 03, 2008 12:51 am

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

User avatar
Artemis Artium
Registered User
Posts: 31
Joined: Sun Jan 25, 2009 2:47 am

Re: Adding Google AdSense after first post

Post by Artemis Artium » Thu Jul 09, 2009 3:19 am

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.
TOG Community Manager
www.TheOriginalGathering.com

User avatar
Nawid
Registered User
Posts: 329
Joined: Sat Jun 27, 2009 4:32 pm
Contact:

Re: Adding Google AdSense after first post

Post by Nawid » Sat Aug 22, 2009 10:02 am

no update? I'm also interested in this....
Image
Check SuperNova Orange style on:
SchoolLife.nl
phpBB.com

Joseppi
Registered User
Posts: 10
Joined: Tue Jun 09, 2009 7:41 pm

Re: Adding Google AdSense after first post

Post by Joseppi » Fri Oct 16, 2009 5:55 pm

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.

User avatar
stickerboy
Former Team Member
Posts: 7349
Joined: Mon Mar 29, 2004 2:27 pm
Location: Airdrie, UK (127.0.0.1)
Name: Kenny Cameron
Contact:

Re: Adding Google AdSense after first post

Post by stickerboy » Sat Oct 17, 2009 11:21 am

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 ;)
I'm a web-designing code-decrypting tech-support musician
|| Twitter || Flickr || phpBB Snippets ||
Formerly known as cherokee red

motzned
Registered User
Posts: 29
Joined: Tue May 10, 2005 9:51 pm
Location: Austria
Contact:

Re: Adding Google AdSense after first post

Post by motzned » Thu Nov 12, 2009 7:18 pm

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',
Author of xabbBlue for phpBB3

jinkazama75
Registered User
Posts: 13
Joined: Sat Nov 28, 2009 11:21 am

Re: Adding Google AdSense after first post

Post by jinkazama75 » Mon Dec 07, 2009 3:07 am

is it possible to add an avatar to ad user?

User avatar
CrazyDave
Registered User
Posts: 72
Joined: Mon Jun 22, 2009 9:15 pm
Location: Las Vegas, NV. USA

Re: Adding Google AdSense after first post

Post by CrazyDave » Thu Dec 02, 2010 8:05 pm

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 :?

martn
Registered User
Posts: 1
Joined: Sun Jan 30, 2011 12:36 pm

Re: Adding Google AdSense after first post

Post by martn » Sun Jan 30, 2011 12:40 pm

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

Locked

Return to “[3.0.x] MOD Writers Discussion”