ASP  «Prev  Next»

Lesson 8Controlling advertisement rotation with the schedule file
Objective Create a schedule file to control the display and rotation of ads.

Controlling Advertisement Rotation with Schedule File

The schedule file[1] is the "command center" for the Advertisement Rotator component. The schedule file contains details concerning the ads, including:
  1. Size of the advertisement space
  2. Image files to use
  3. Percentage of time that each file should be displayed

The schedule file is split into two sections:
  1. a global section that has global settings (such as the size of the banner image), and
  2. a section for individual banners that has the following format:

REDIRECT /scripts/adredirect.asp 
WIDTH 400
HEIGHT 55
BORDER 1
*
http://sixties–bands/ads/sixtiesbands.gif 
http://www.old–rock–stars.com/
Swap memories and memorabilia with other fans of
 sixties bands.
20
http://www.wolfgang–a–mozart.com/ads/requiem.jpeg 
–
Call for our tours of Salzburg, Mozart's home:
 (800) 555–3245
20
http://lunar–explorer/ads/crescent.gif 
http://lunar–explorer/package–tours/
Join us for a virtual tour of the moon.
80

In this sample, named schedule.txt, all the optional values are set in the first section, and the second section lists three URLs. Notice that the second URL (http://www.wolfgang-a-mozart.com/) doesn't have a home page, a phone number is displayed in the alt text instead.

Setting up the Advertisement Rotator


<% adRotate = Server.CreateObject("MSWC.AdRotator") %>  
<%= adRotate.GetAdvertisement("/ads/schedule.txt") %>
When the script is processed ASP runs the GetAdvertisement() method, which then looks in the schedule file and gets the information for the next advertisement. The ad information is then turned into HTML for display on the page:

<A HREF="/scripts/adredir.asp?<http://www.old–rock–stars.com/"> 
<IMG SRC="http://sixties–bands/ads/sixtiesbands.gif" 
ALT="Swap memories and memorabilia with other fans of sixties bands." 
WIDTH=400 HEIGHT=55 BORDER=1></A>
Question: Where does the GetAdvertisement method look to find which advertisement to display next?
Answer: The schedule file.

[1]Schedule file: A file which holds instructions for the order and/or frequency that ads will appear in the Ad Rotator Component.