Page 1 of 1

Inserting ads in phpBB3

Posted: July 25th, 2012, 7:51 pm
by NewsEditor
This post have its content collected from the following source:
phpBB Knowledge Base - Inserting ads in phpBB3

Before you implement any of what is suggested in this post, as a preparation to avoid damage and understand what you are doing and why; FIRST please read this post TO THE END and open the above linked original article in the phpBB Knowledge Base.

It is a good idea to make as little modification as possible to phpBB core files, so that the upgrade procedure can work without troubles. This way, every time you want to modify your ads policy/provider you just have to modify the files under directory "<your forum root>/ads/".

Create the following files:

1) <your forum root>/ads/index.html
2) <your forum root>/ads/viewforum.html
3) <your forum root>/ads/viewtopic.html

(directory "<your forum root>/ads" must be created as it is not part of phpBB3)

Insert your ads code in the above (three) files as it is provided from your ad provider, for instance Google Adsense between the body-tags.

Then make the following modifications:

1) open file <your forum root>/styles/<style name>/template/index_body.html and after the line

Code: Select all

<!-- INCLUDE overall_header.html -->
insert

Code: Select all

<!-- INCLUDE ../../../ads/index.html -->

2) open file <your forum root>/styles/<style name>/template/viewforum_body.html and after the line

Code: Select all

<!-- INCLUDE overall_header.html -->
insert

Code: Select all

<!-- INCLUDE ../../../ads/viewforum.html -->

3) open file <your forum root>/styles/<style name>/template/viewtopic_body.html and after the line

Code: Select all

<!-- INCLUDE overall_header.html -->
insert

Code: Select all

<!-- INCLUDE ../../../ads/viewtopic.html -->

4) save and close all files


PLEASE NOTE: for this modification to be effective you must clear the cache (there is a button for that in the ACP home page).

Re: Inserting ads in phpBB3

Posted: July 25th, 2012, 8:36 pm
by daxion
The procedure described here produce ads in the location and manner seen on this picture:
Image

Apparently, this is used at this web site.

Re: Inserting ads in phpBB3

Posted: July 25th, 2012, 9:13 pm
by NewsEditor
This post have its content collected from the following source:
Knowledge Base - Advertisements in phpBB3

It is so important, I will repeat myself; Before you implement any of what is suggested in this post, as a preparation to avoid damage and understand what you are doing and why; FIRST please read this post TO THE END and open the above linked original article in the phpBB Knowledge Base.

Important note: Check with your ad provider before you put your ads in the header or footer. Some providers (like Google AdSense) only allow ads on pages that have actual content like the view topic or view forum pages.


Ads in the header
If you want ads in your header, open styles/<style name>/template/overall_header.html and add your code at the very end of the file.


Ads in the footer
If you want ads in your footer, open styles/<style name>/template/overall_footer.html

Find:

Code: Select all

<!-- IF U_ACP --><br /><strong><a href="{U_ACP}">{L_ACP}</a></strong><!-- ENDIF -->
Add your code after that line. You may need to include one or two <br /> to get line breaks (newlines) if you so desire.


Ads before or after the first post in a topic
If you want ads either before or after the first post in a topic, open styles/<style name>/template/viewtopic_body.html.

For ads before the first post, find the line below and add the sample code after this line.

Code: Select all

<!-- BEGIN postrow -->
For ads after the first post, find the line below and add the sample code before this line.

Code: Select all

<!-- END postrow -->
Here is the sample ad code:

Code: Select all

   <!-- IF postrow.S_FIRST_ROW -->
   <div class="post bg2">
      <div class="inner"><span class="corners-top"><span></span></span>

      <div class="postbody">
         <h3>{postrow.POST_SUBJECT}</h3>
         <p class="author"><strong>Sponsor</strong></p>

         <div class="content" style="text-align: center;">
            Insert your ad code here
         </div>
      </div>
      
      <dl class="postprofile" id="profile0000">
         <dt>
            <strong>Sponsor</strong>
         </dt>

         <dd> </dd>
      </dl>
      
      <div class="back2top"><a href="#wrap" class="top" title="{L_BACK_TO_TOP}">{L_BACK_TO_TOP}</a></div>
      <span class="corners-bottom"><span></span></span></div>
   </div>
   <hr class="divider" />
   <!-- ENDIF -->
Of course, replace "Insert your ad code here" with the ad code your provider gives you.

If you created the folder for html files, as suggested earlier in this topic, you might want to create a file in <your forum root>/ads/ folder [i.e. for example afterpost.html] and use the method with a .html file instead of inserting all this sample code in the viewtopic_body.html, but only the code provided by your ad provider into the .html file in your /ads/ folder.

PLEASE NOTE: for this modification to be effective you must clear the cache (there is a button for that in the ACP home page).

Re: Inserting ads in phpBB3

Posted: July 25th, 2012, 10:27 pm
by daxion
After a small alteration, by totally ignoring the sample code and creating a .html file in the /ads/ folder, I created what we see on this forum; an ad after each post. It looks like this:

Image

However, it looks like Google Adsense is not publishing more than three ads on the same page. I guess, this is really good... can't be too much, people are easily annoyed by all the commercials they are exposed to everywhere.

Re: Inserting ads in phpBB3

Posted: July 25th, 2012, 10:59 pm
by NewsEditor
If you prefer to have your advertisements managed and measured to some extent there are several options, of course. Here is a phpBB3 MOD that could be of interest:

Advertisement Management MOD for phpBB
Image



If you are ready for the next level I already posted about the OpenX Source™ - Free advertisement management script, where you can manage, control and measure your advertisements on all your sites from one place.

Re: Inserting ads in phpBB3

Posted: July 11th, 2014, 10:56 pm
by daxion
This could be worth reading as well;
Google AdSense with Revive Adserver

The "Revivie Adserver" script is also ideal for managing affiliate program banners and/or mixing them with Google Adsence.

I truly appreciate this forum topic.Thanks Again. Fantastic.

Posted: September 18th, 2016, 11:11 am
by RobertEt
I truly appreciate this forum topic.Thanks Again. Fantastic.