6.8. Banner/Ad rotation

Interchange has a built-in banner rotation system designed to show ads or other messages according to category and an optional weighting.

The [banner ...] ITL tag is used to implement it.

The weighting system pre-builds banners in the directory 'Banners,' under the temporary directory. It will build one copy of the banner for every one weight. If one banner is weighted 7, one 2 and one 1, then a total of 10 pre-built banners will be made. The first will be displayed 70 percent of the time, the second 20 percent and the third 10 percent, in random fashion. If all banners need to be equal, give each a weight of 1.

Each category may have separate weighting. If the above is placed in category tech, then it will behave as above when placed in [banner category=tech] in the page. A separate category, say art, would have its own rotation and weighting.

The [banner ...] tag is based on a database table, named banners by default. It expects a total of five (5) fields in the table:

code

category

weight

rotate

            non-zero, non-blank: Rotating ads
            blank:               Ad not displayed
            0:                   Ad is entire contents of banner field

banner

Interchange expects the banner field to contains the banner text. It can contain more than one banner, separated by the string '{or}.' To activate the ad, place any string in the field rotate.

The special key "default" is the banner that is displayed if no banners are found. (Doesn't apply to weighted banners.)

Weighted banners are built the first time they are accessed after catalog reconfiguration. They will not be rebuilt until the catalog is reconfigured or the file tmp/Banners/total_weight and tmp/Banners/<category>/total_weight is removed.

If the option once is passed (i.e., [banner once=1 weighted=1], then the banners will not be rebuilt until the total_weight file is removed.

The database specification should make the weight field numeric so that the proper query can be made. Here is the example from Interchange's demo:

   Database   banner   banner.txt   TAB
   Database   banner   NUMERIC      weight

Examples:

weighted, categorized

            code    category   weight   rotate   banner
            t1      tech       1                 Click here for a 10% banner
            t2      tech       2                 Click here for a 20% banner
            t3      tech       7                 Click here for a 70% banner
            a1      art        1                 Click here for a 10% banner
            a2      art        2                 Click here for a 20% banner
            a3      art        7                 Click here for a 70% banner
            [banner weighted=1 category="tech"]

weighted

            [banner weighted=1]
            code    category   weight   rotate   banner
            t1      tech       1                 Tech banner 1
            t2      tech       2                 Tech banner 2
            t3      tech       7                 Tech banner 3
            a1      art        1                 Art banner 1
            a2      art        2                 Art banner 2
            a3      art        7                 Art banner 3

categorized, not rotating

            [banner category="tech"]
            [data table=banner col=banner key=tech
            code    category   weight   rotate   banner
            tech               0        0        Tech banner
            [banner category="[value interest]"]

categorized and rotating

            [banner category="tech"]
            code    category   weight   rotate   banner
            tech               0        1        Tech banner 1{or}Tech banner 2
            art                0        1        Art banner 1{or}Art banner 2
            [banner category="[value interest]"]

multi-level categorized

            [banner category="tech:hw"] or [banner category="tech:sw"]
            code    category   weight   rotate   banner
            tech               0        1        Tech banner 1{or}Tech banner 2
            tech:hw            0        1        Hardware banner 1{or}HW banner 2
            tech:sw            0        1        Software banner 1{or}SW banner 2

Advanced

            [banner
                weighted=1*
                category=category*
                once=1*
                separator=sep*
                delimiter=delim*
                table=banner_table*
                a_field=banner_field*
                w_field=weight_field*
                r_field=rotate_field*
            ]
            table       banner    selects table used
            a_field     banner    selects field for banner text
            delimiter   {or}      delimiter for rotating ads
            r_field     rotate    rotate field
            separator   :         separator for multi-level categories
            w_field     weight    rotate field