So far, the most common formats of displaying banners on Web sites rely on GIF, JPG and Flash files. For banner formats of GIF and JPG, this can be done the same way. However, when comes time to display a Flash banner on a site, the code behind it, for its display purposes, is different.
Width and Height
The first question that could come to your mind would be why do we have to pass the width and height of the banner file. As you may know, it is easy to get those values by the use of an Image object. The reason is that sometimes you may want to display the banner with a width and height different than what is defined in the banner file. As HTML allows you to do that, this can be useful sometimes. As for a Flash file, there is no easy way to know what is the base width and height. A Flash file can also be displayed without loosing that much quality even if we do not pass the proper dimensions. For those reasons, I prefer to pass the width and height as parameters.
One requirement to use this function is to rely on a primary key for the banner identification which can be bound on a DBF table. Even if you do not have a DBF table, it is still possible to use this function by properly naming your banner files by padding them right by the use of 6 characters such as 000001.jpg.
Another requirement is to have a gcClientFat variable which holds the FAT root equivalent of your Web site. This can be adjusted to fit your own needs.
How to call it?
The process of calling this function is really simple. Here is an example:
lcHtml=GetBannerProperFormat(PrimaryKey,400,77,'This is my tooltip','Image',;
The GetBannerProperFormat() function
Here is the code of the GetBannerProperFormat() function:
* expN1 Banner ID
* expN2 Width
* expN3 Height
* expM1 Tooltip
* expC1 Class
* expC2 Directory
* expC3 URL
* If we have a URL
So, basically, if you have a banner table having 20 records, you should have 20 files in your banner directory. They can have different extensions as long as they are GIF, JPG or Flash files. Those are pretty much the standard files you may use for banners on Web sites. If you ever have a need to handle additional types, you may adjust the function as needed.
Overview of the generated HTML code
The following provides an overview of a generated HTML code based on a GIF file:
<IMG SRC=Images/Banner/000019.jpg WIDTH=132 HEIGHT=100 TITLE="My tooltip" BORDER=0
The following provides an overview of a generated HTML code based on a Flash file:
width="400" height="77" Class=Image>
<param name=movie value="Images/Banner/000037.swf">
<param name=quality value=high>
<embed src="Images/Banner/000037.swf" quality=high
type="application/x-shockwave-flash" width="400" height="77">
The process of displaying a GIF or JPG banner is not that much difficult. Many would simply avoid using a function for that. But, this function is generic and is mostly useful when you have to deal with those Flash file. The code to generate the display of a Flash file on a Web site is much more complicated and can be simplified by the use of this function.