This is my includes/modules/banner_rotator.php
There are a few changes to the standard file, but the thrick is at the top where a cPath switch is made.
futher I have a BANNER_ROTATOR_GROUP defined as 'C' and different group names named according to the cPath they apply to
so C1_11_21 would trigger the image to be displayed for category 21, 11 and 1
secondly the else switch finds matches in the categories directory (where I have these stored) based on the manufacturers name, this logic is purely based on image naming conventions, as it finds banners starting with the manufacturers name (with spaces replaced by underscores.
The module is included in index.php section where you want the banner to show up.
Hope this helps
Carine
<?php
/*
$Id: banner_rotator.php 1.1 20100628 Kymation $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2010 osCommerce
Released under the GNU General Public License
*/
if ($cPath <> '') {
$where_clause = " banners_group like '" . BANNER_ROTATOR_GROUP . "$cPath%' ";
} else {
$where_clause = " banners_image like 'categories/" . str_replace(" ", "_",strtolower($manresult['manufacturers_name'])). "%' ";
}
$banner_query_raw = "
select
banners_id,
banners_url,
banners_image,
banners_html_text
from
" . TABLE_BANNERS . "
where
$where_clause
order by
" . BANNER_ORDER . "
limit
" . MAX_DISPLAY_BANNER_ROTATOR
;
// made it language independent
// and language_id = '" . ( int )$languages_id . "'
//
//print $banner_query_raw; exit();
$banner_query = tep_db_query( $banner_query_raw );
//print tep_db_num_rows( $banner_query );exit();
if( tep_db_num_rows( $banner_query ) > 1 ) {
?>
<!-- banner_rotator -->
<div id="bannerRotator">
<ul>
<?php
while( $banner = tep_db_fetch_array( $banner_query ) ) {
//print_r($banner);exit();
//preventief alle flash-animaties weglaten (anders worden ze in een img-tag gezet, hetgeen niet werkt)
if(substr($banner['banners_image'], -3, 3) == 'swf')
continue;
echo ' <li>';
if( $banner['banners_url'] != '' ) {
echo '<a href="' . tep_href_link( FILENAME_REDIRECT, 'action=banner&goto=' . $banner['banners_id']) . '" target="_blank">';
}
echo tep_image( DIR_WS_IMAGES . $banner['banners_image'], $banner['banners_html_text'] );
if( $banner['banners_url'] != '' ) {
echo '</a>';
}
echo '</li>';
tep_update_banner_display_count( $banner['banners_id'] );
}
?>
</ul>
<div id="bannerNav"></div>
</div>
<div class="divider-tall"></div>
<!-- banner_rotator_EOF -->
<?php
} elseif( tep_db_num_rows( $banner_query ) == 1 ) {
$banner = tep_db_fetch_array( $banner_query );
//echo tep_display_banner('preview', $banner['banners_id']);
if (tep_not_null($banner['banners_html_text'])) {
$banner_string = $banner['banners_html_text'];
} else {
if ( substr($banner['banners_image'], -3, 3) == 'swf' ) {
$size = getimagesize(DIR_WS_IMAGES . $banner['banners_image']);
if (tep_not_null($banner['banners_url'])) {
$banner_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $banner['banners_id']) . '" target="_self">' . mm_output_flash_movie( $banner['banners_title'], DIR_WS_IMAGES . $banner['banners_image'] , $size[0] , $size[1]) . '</a>';
} else {
$banner_string = mm_output_flash_movie( $banner['banners_title'], DIR_WS_IMAGES . $banner['banners_image'] , $size[0] , $size[1]);
}
} else {
if (tep_not_null($banner['banners_url'])) {
$banner_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $banner['banners_id']) . '" target="_self">' . tep_image(DIR_WS_IMAGES . $banner['banners_image'], $banner['banners_title']) . '</a>';
} else {
$banner_string = tep_image(DIR_WS_IMAGES . $banner['banners_image'], $banner['banners_title']);
}
}
}
tep_update_banner_display_count($banner['banners_id']);
//next css classes enforce same layout as the rotator, but images doesn't flash, nor is there a navigation bar
?>
<div id="bannerRotator">
<ul>
<?php echo $banner_string;?>
</ul>
</div>
<div class="divider-tall"></div>
<?php
}
?>