Integrate Google Ads to Simple Machines Forum software (SMF Integration)

spiros · 7 · 9585

spiros

  • Administrator
  • Hero Member
  • *****
    • Posts: 824493
    • Gender:Male
  • point d’amour
Adding Google ads in a pseudopost between topic and reply

This applies only to webmasters who have the SMF forum and want to integrate Google ads. The following hack ads an extra pseudo post after the first post.

You can alter the formatting ad libitum by changing the colour parameters for Google ads as well as the td background-color:

Code: [Select]
<tr align=center><td style="padding: 0 0 1px 0; border: 1px solid #7A7777;
background-color: #6B8EAE;">

If you remove the "border: 1px solid #7A7777;" bit then the border will not be properly displayed.

The only problem is that when no ad is available there is an empty space with 60 pixels height... and I found no way of getting rid of that.

See the ad working here or just scroll down to the end of this message.
https://www.translatum.gr/forum/index.php?topic=272.0

FIND IN THE display.template.php (default theme)

Code: [Select]
// Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']))
echo '
<hr width="100%" size="1" class="hrcolor" />
<div style="overflow: auto; width: 100%; padding-bottom: 3px;" class="signature">', $message['member']['signature'], '</div>';

echo '
</td>
</tr>
</table>
</td></tr>
</table>
</td></tr>';
}


Just before the } at the end there ADD:


Code: [Select]
echo '
<tr align=center><td style="padding: 0 0 1px 0; border: 1px solid #7A7777; background-color: #6B8EAE;">
<script type="text/javascript"><!--
google_ad_client = "pub-6539986036551354";
google_alternate_ad_url = "https://www.translatum.gr/empty.html";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_channel ="1128379812";
google_color_border = "6B8EAE";
google_color_bg = "6B8EAE";
google_color_link = "000000";
google_color_url = "666666";
google_color_text = "333333";
//-→</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td></tr>';

Adding Google ads on top as a message in a board

In this case you mofidy index.template.php.

You can make google ad appear on top of the forum, as a message in a board (See "Sponsored translation links" above).

Here is the code (default theme, SMF 1.0). I guess you should be able to work out what changes you should make to your own.

Code: [Select]

// The main content should go here.  A table is used because IE 6 just can't handle a div.
echo '
<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
<td id="bodyarea" style="padding: 1ex 20px 2ex 20px;">



<div class="tborder">
<table summary="English Greek translation forum, help with French, German, Spanish, Italians language questions and terminology as well as technical help with common computer problems and translation memory tools like Trados, Deja Vu and Wordfast" border="0" width="100%" cellspacing="1" cellpadding="5" height="72">
<tr>
<td  colspan="4" class="catbg2" height="18"><img src="https://www.translatum.gr/forum/Themes/default/images/collapse.gif" border="0" />&nbsp;<u><font size="2">Sponsored translation links</font></u>
</td>
</tr>
<tr class="windowbg2">
<td class="windowbg" width="6%" align="center" valign="middle"><img src="https://www.translatum.gr/forum/Themes/default/images/off.gif" border="0" /></td>
<td align="left" valign="middle">
<script type="text/javascript"><!--
google_ad_client = "pub-6539986036551354";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_channel ="9841008541";
google_color_border = "EFEFEF";
google_color_bg = "EFEFEF";
google_color_link = "000000";
google_color_url = "000000";
google_color_text = "000000";
//-→</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>


<td valign="middle" align="center" style="width: 12ex; background-color: #DFDFDF">
<p align="center"><font size="1">1 Post in<br>1 Topic</font></td>
<td align="left" width="22%">
<font size="1">Last Post on April 04, 2005,<br>12:00:00 PM<br>in <u>English dictionary</u> by <u>Google</u></font></td>

</tr>
</table>
</div>';
}
function template_main_below()


What is Google AdSense?

Google AdSense is a fast and easy way for website publishers of all sizes to display relevant, unobtrusive Google ads on their website's content pages and earn money. Because the ads are related to what your users are looking for on your site, you'll finally have a way to both monetize and enhance your content pages. Learn more about AdSense for content.

It's also a way for web site publishers to provide Google search to their site users, and to earn money by displaying Google ads on the search results pages. Find out more about AdSense for search.

The program is free, and Google pays you for valid clicks on the ads on your site or search results pages. So go ahead and try this program. If you comply with our program policies, just complete our online application and select either or both of AdSense for content pages and AdSense for search. One application gets you approved for both AdSense and AdSense for search - you can decide to use any combination of these products on your pages.
« Last Edit: 02 Nov, 2005, 10:40:28 by spiros »


RobRFF

  • Semi-Newbie
  • *
    • Posts: 2
Great tip, but I am having problems with it showing ads in the first THREE posts. How do I make it appear in only one post??

Rob - http://forum.realityfanforum.com



spiros

  • Administrator
  • Hero Member
  • *****
    • Posts: 824493
    • Gender:Male
  • point d’amour
Rob,

I think some "if / if not" statement should do the trick. I.e. "if this is the first reply display it", "if not" do not display it.

I am not sure what the exact php code would be, so perhaps it would be worth asking at SMF forum.

Mind you, are you sure you implemented the code correctly? As far as I can see I only get one ad in the first reply.

See here for example: https://www.translatum.gr/forum/index.php?topic=503.0

Also, I use SMF 1 and if you use 1.1 some things might have changed which prevent this code from running the same way.

By the way, the ads with the highest conversion rate are those on top (like in this forum) so I would recommend doing that instead.
« Last Edit: 23 Jul, 2005, 00:56:39 by spiros »


RobRFF

  • Semi-Newbie
  • *
    • Posts: 2
I figured there was going to have to be a little playing around with it. I am sure I have copied the code right, and added it in right, but thought maybe it was something little I was overlooking.

Thanks for the help!

Rob



n0x

  • Semi-Newbie
  • *
    • Posts: 1
where are we going to put the code for top of the page? in display.template.php ? i can't do this .


spiros

  • Administrator
  • Hero Member
  • *****
    • Posts: 824493
    • Gender:Male
  • point d’amour

swimgod

  • Guest
does anyone realize if the first poster has no signiture enabled the ads will not be displayed?

ill work on fixing this problem since i know php well...
:P
and because my partner installed this script


EDIT:
this is for adding the ads after the last post...
Code: [Select]
//
//Start Google Ads mod
$i = 0;
$i = $i+1;
$last_post = ($i = 1)? TRUE : FALSE;
if($last_post === TRUE){
echo '
<tr align=center><td style="padding: 0 0 1px 0; border: 1px solid #7A7777; background-color: #F3F3F3;">
<script type="text/javascript"><!--
google_ad_client = "pub-3986854913098729";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "336699";
google_color_link = "425a65";
google_color_bg = "FFFFFF";
google_color_text = "000000";
google_color_url = "425a65";
//-→</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td></tr>';
}
//End Google Ads mod
//
put this AFTER the } in the statment told to find in the first post in this topic :)

have fun :P
« Last Edit: 03 Jun, 2006, 12:52:39 by spiros »


 

Search Tools