How to show advertisements in PHP-Nuke blocks

20.7. How to show advertisements in PHP-Nuke blocks

Advertisements are a popular source of revenue for webmasters. It doesn't take long until the young webmaster feels attracted to the sirene call of affiliate programs, banners or context relevant advertising.

Advertisements are often created through the use of a Javascript function, called at the right place in the HTML code. We have already treated the subject of Javascript in PHP-Nuke blocks (see Section 20.5) and modules (see Section 21.9) and seen that Javascript does not pose any special problems with PHP-Nuke. However, due to the increasing popularity of Google's AdSense program, there has been an increasing demand for ready-to-use solutions in the PHP-Nuke field. The following code examples should be seen as representative examples of how such advertising functionality can be incorporated in PHP-Nuke blocks. You can use them as starting point for similar advertising solutions, as offered by today's modern search engines or affiliate programs.

Tip Ready-to-use Google AdSense Block

If you don't feel like writing your own Google AdSense block, just use a ready-made one! Go to and download a ready-to-use AdSense block.

Create a block called block-AdSense.php and add the following in the file:

if (eregi("block-AdSense.php",$PHP_SELF)) {
  Header("Location: index.php");
<script language="JavaScript">
google_ad_client = 'your client-number';
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = '468X60_as';
google_color_border = "E5E5E5";
google_color_bg = "E5E5E5";
google_color_link = "336699";
google_color_url = "000000";
google_color_text = "000000";
// -->
$content .= "<center><script language=\"JavaScript\"
$content .= "</script></center>";
Important Don't forget:

Add your Google client number in the script.

Activate the AdSense block in your administration panel (see Section 9.4) by clicking on the "Blocks" links and choosing it from the blocks list as a new block.

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,468,309
  • Today: 4,849
Server InfoServer Info
  • Sep 26, 2017
  • 01:56 am PDT

Daily Inspiration