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\"

just before that, add the following:

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" bgcolor=\"#FFFFFF\"
."<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"160\">\n"
."<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" bgcolor=\"#FFFFFF\"
."<tr><td align=\"center\">\n"
."<font class=\"title\" size=\"1\"><b>Related Websites</b></font>\n"
."<td bgcolor=\"#FFFFFF\"><font size=\"1\">";
<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 type="text/javascript"
echo "</td>\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: 349,890,908
  • Today: 9,279
Server InfoServer Info
  • Mar 21, 2018
  • 02:09 am PDT

Daily Inspiration