HomePHP Page 3 - Implementing Ad Support Into Your Site With PHPAdsNew
Using PhpAdsNew&toc - PHP
PhpAdsNew is one of the most popular open source ad projects on the Internet. We use it right here on devArticles to manage ads for our advertisers, and I would honestly have to say that it's the best ad management system I've ever used. In this article Mitchell's going to give you a guided tour of PhpAdsNew, including how to install it, how to create your first banner, and also how to create your first banner rotation.
PhpAdsNew has zones, clients, and banners. First off, we want to add a client, so click on the administration tab and then the add new client link. Complete the details of the client when the page loads. Before you click on the save changes button, you should think carefully about whether or not you would like to allow this client to login to your PhpAdsNew system and modify his campaign.
If you'd like to give your clients the flexibility of changing their banner whenever they like, then you should enter a username and password for them and select the appropriate checkboxes for them, which are shown below:
When you're done, click on the save changes button. PhpAdsNew will now let you create a new campaign for this client. The great thing about PhpAdsNew is that you can either set how many impressions this clients ad will have, you can set both activation and expiry dates for the ad, or you can just let the ad run for as long as you like.
The weight field is the frequency that the ad will be shown. The default is 1, but you can set it to a higher value if you'd like the ad to appear more frequently than any others if it's in a rotation.
Set the options for this clients campaign then click save changes. PhpAdsNew will create the new campaign and redirect you back to the zones page. To create a banner for this client, click on the create link under their campaign:
Once the add new banner page loads, there are four possible types of banners that we can create:
Banner stored in SQL: This option allows you to upload an image directly into the PhpAdsNew MySQL database. It's stored as a blob, and you don't have to worry about storing image files on your server.
Banner stored on the Webserver: If you'd like to store your banner images on your webserver, then choose this option.
Banner references to through URL: This option allows you to reference a banner that's available online (i.e. http://...). If you're running banners as part of an ad network, then this is the option that you're after.
HTML banner: HTML banners are ideal for rich media ads such as flash movies, or even plain text ads, which generally have a great click-thru rate (CTR).
For this article, we'll create a banner stored in SQL, so select that option and choose/create a banner from your hard drive. I have created a simple 468x60 banner. Once you click on the submit ad button, PhpAdsNew will show you how your banner will look. Here's what mine looked like:
Now that our banner's created, it's time to tell PhpAdsNew to generate the banner code for it, which we can include in our web pages to display the banner. Click on the administration tab and then the generate banner code link, just under the tab. Once again, there are several options to choose from. The way the banner is invocated can be one of five possible options:
Remote Invocation: An image tag will be generated that points to the location of PhpAdsNew's adview.php script, passing in the ID of the client whose banner we want to display.
Remote Invocation for iFrames: Generates an iframe tag that references adframe.php. Adframe.php returns the image so it's displayed inside of the iFrame.
Local Mode: PHP code that includes phpadsnew.inc.php and calls that scripts view function. This is the default mode, however if you're using MySQL in other areas of your site to display data, then I would recommend staying away from this option.
Once you've chosen your banner display options, you'll need to select the banner to be displayed from the ClientID drop down list. If you'd like the URL that the banner links to open in a new window, enter something like _blank in the target field. In this example I'm using remote invocation, so here's the code that PhpAdsNew generated when I clicked on the generate button: