Making an EZ Banner Script…

By | May 10, 2010

osCommerce comes with banner functinality already, but it’s not the greatest system out there. Certainly useable though.

I was tasked to come up with a system which would allow the site owner to maintain a hands off system of linking a banner to a product or category or page in osCommerce. The customer did not want anything fancy like counting the number of clicks, graphs etc.

What the customer did want was the ability to fade the pictures in and out, you see this on a number of sites just now – off the top of my head I can’t think of any, but I’m sure everyone reading this knows the effect that I mean.

Anyway, with some lateral thinking I came up a concept which allows the shop owner to upload images into a certain directory. These images have to have certain names. Eg: p-123.gif would link to product id 123. c-3.jpg would link to category id 3, and f-name.gif to go to the given page in the shop (eg, a link to conditions.php) – jpg, gif, png can all be used.

I then came up with some code to extrapolate the necessary information from the filename and link to whatever is neccessary. Kind of hard to explain, but this is the basis of the code;

[php]$to_show .= ‘

  • ‘ . tep_image($img) . ‘
  • ‘;[/php]

    Which outputs something like this in HTML;


  • [/php]

    Obviously the more images, the more links, each link going to the correct place. As I am putting each of these links into a list, I can now easily join the jQuery Innerfade script to allow the fading effect.

    How easy to use?

    Well, to add in a new link, the shop owner simply creates an image, names it correctly and uploads it to the images directory. To remove a link is just as easy – simply delete the image. All the code is auto updated! Easy as 123.

    Leave a Reply

    Your email address will not be published.