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.
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 http://home.vie4life.com/downloads-cat-13.html and download a ready-to-use AdSense block. |
Create a block called block-AdSense.php and add the following in the file:
<?php if (eregi("block-AdSense.php",$PHP_SELF)) { Header("Location: index.php"); die(); } ?> <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"; // --> </script> <?php $content .= "<center><script language=\"JavaScript\" src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">"; $content .= "</script></center>"; ?> |
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.