PHP
  Home arrow PHP arrow Page 6 - Commercial Break (A phpAds Primer)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Commercial Break (A phpAds Primer)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2002-07-30


    Table of Contents:
  • Commercial Break (A phpAds Primer)
  • Getting Started
  • The Toy Store
  • Different Strokes
  • Room With A View()
  • The Advanced Course
  • Access Denied
  • The Number Game
  • Endgame

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Commercial Break (A phpAds Primer) - The Advanced Course
    ( Page 6 of 9 )

    You'll remember that only the first argument to view() is compulsory - all the rest are optional. However, these optional arguments can come in pretty handy at times. For example, let's suppose you have a client who's paid you a premium to display only his banners on a particular page of your site. However, the view() function, by itself, displays a random customer's banner each time it is invoked. Not a Good Thing at all.

    You can modify this default behaviour of the view() function by passing it a second argument, a client ID. This forces view() to only displays banners belonging to that client when it is invoked, and can come in handy when you want to mark certain pages as exclusive to particular customers. Here's an example, which only displays banners belonging to customer ID 21.

    <? view("teenagers", 21); ?>
    By default, clicked banners open up in the same browser window - which may not be acceptable to you. You can use the third argument to view() to specify a different target for clicks - as in the following example, which launches the target of each banner in the window named "ad".

    <? view("teenagers", 21, "ad"); ?>
    The fourth argument to view() is a Boolean, which allows you to hide or show the optional text under the banner. By default, the text display is turned off; you can turn it on with something like this.

    <? view("teenagers", 21, "ad", true); ?>
    The last optional argument to view() is probably also the most complex - it is used as a filter to restrict the banners displayed. It consists of an array, which in turn consists of one or more associative arrays. Each of these associative arrays contains a key - which must be either the equality operator == or the inequality operator != - and a value, which must be a banner ID. This series of nested arrays is used by phpAds to provide very focused control over which banners can appear on which pages.

    Consider the following example, which displays two banners on the same page. Since the selection of banners is random, it's possible that the same banner could be repeated in both places. You can avoid this by creative use of the banner filter, as in the example below.

    <? require("phpAds/config.inc.php3"); require("phpAds/view.inc.php3"); require("phpAds/acl.inc.php3"); ?> <html> <head> <basefont face="Arial"> </head> <body> <table height="100%" width="100%" border="0" cellspacing="5" cellpadding="5"> <tr> <td align="center"><? $id = view("studio"); ?></td> </tr> <tr> <td height="100%" width="100%" valign="top" bgcolor="silver" align="left"> <h2>Sample page</h2> <center> Content here <p> Content here <p> Content here <p> </center> </td> </tr> <tr> <td align="center"><? view("studio", NULL, NULL, true, array(array("!=" => $id))); ?></td> </tr> </table> </body> </html>
    In this case, the first call to view() returns a banner whose ID is stored in the PHP variable $id. The second call to view() then uses this $id variable, in combination with an inequality operator, to ensure that the same banner does not get repeated.

    You can reverse things so that the same banner appears at both the top and bottom of the page, by using the equality operator instead of the inequality operator in the example above. Try it yourself and see.

     
     
    >>> More PHP Articles          >>> More By Harish Kamath, (c) Melonfire
     

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek