Google AdSense in the News module

21.11.1. Google AdSense in the News module

Wouldn't it be nice to have your Google AdSense placed just right to a news article? The solution we will present here, taken from Google AdSense in PHP-Nuke, can be used as a starting point for introducing AdSense (and other similar advertisement schemes) in modules other than the News module.

In file modules/News/article.php, look for the following code:

$boxtitle = ""._RELATED."";
$boxstuff = "<font class=\"content\">";
$sql = "select name, url from ".$prefix."_related where tid=$topic";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$name = $row[name];
$url = $row[url];
$boxstuff .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"$url\"
target=\"new\">$name</a><br>\n";
}

just before that, add the following:

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" bgcolor=\"#FFFFFF\"
width=\"160\"><tr><td>\n"
."<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"160\">\n"
."</table>\n"
."<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" bgcolor=\"#FFFFFF\"
width=\"100%\">\n"
."<tr><td align=\"center\">\n"
."<font class=\"title\" size=\"1\"><b>Related Websites</b></font>\n"
."</td></tr>\n"
."<tr>\n"
."<td bgcolor=\"#FFFFFF\"><font size=\"1\">";
?>
<center>
<script type="text/javascript"><!--
google_ad_client = "your client-number";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "336699";
google_color_url = "000000";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>
<?php
echo "</td>\n"
."</tr>\n"
."</table></td></tr></table>\n"
."<br>\n\n\n";

In the above code, you can recognize the Google AdSense Javascript, also used in Section 20.7 to show AdSense in a PHP-Nuke block, in the middle of a table layout construction.

Important Don't forget:
 

Add your Google client number in the AdSense script.


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

 

Site Info v2.2.2

Last SeenLast Seen
Server TrafficServer Traffic
  • Total: 337,476,387
  • Today: 12,927
Server InfoServer Info
  • Sep 26, 2017
  • 04:00 am PDT
 
 

Daily Inspiration