Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Sub-Category Banner


6 replies to this topic

#1 dreamingdesign

  • Community Member
  • 1 posts
  • Real Name:Stephane Masetto

Posted 11 July 2011, 08:34

Hi,

I wanted to allocate an individual banner to each of the sub-category of my beauty products website.

I am not talking about the category image but a banner or advertising like image.

Please have a look at: http://www.stella-marketing.com/cetuem_01/

I am only starting with PHP, so I decided to get the Category Name variable in the index.php page and to use it as my image.

In the index.php page find:

<h1><?php echo $catname; ?></h1>

And add just bellow (or whenever you like this banner to be):

<?php
$catimagename = $catname . '';
$catimagename = strtolower($catimagename);
$catimagename = str_replace(" ", "_", $catimagename);
?>

<img src="images/<?php echo $catimagename; ?>.png">

The image you like to create need to have the same name as the category/sub-category.

If, for example, you need a picture on top of your Nail Enamels Collection category the name has to be nail_enamels_collection.png

You can create JPG or GIF or else picture format if you change the .png at the and of the last line.
You can change the _ in the picture name by - or else but to replace it with spaces might not be displayed in some system.

I hope it will help someone out there.

PS: Work in progess in my website. All picture will be uploaded by 12th of July 2011

Regards,
Stephane

Attached Files



#2 bruyndoncx

  • Community Member
  • 2,382 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 11 July 2011, 12:13

sweet simple solution !

if you want something more advanced, I have banner rotator from kymation and loaded banners for each category in groups reflecting the category path, so that the top level categories show a collection of banners from all the subcategories.
this setup allows for url links behind the banners, multi-language should you wish, and enable/disable for more flexibility.
Hava a nice day !
Carine Bruyndoncx

KEUKENLUST, Everything but the kitchensink !

#3 wendy_purple

  • Community Member
  • 12 posts
  • Real Name:Wendy
  • Gender:Female

Posted 13 July 2011, 00:18

Hi Carine, I'm interested in the banner rotator for each category.
Please tell me more about this.
Thanks in advance

#4 bruyndoncx

  • Community Member
  • 2,382 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 13 July 2011, 21:47

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	
  }
?>

Hava a nice day !
Carine Bruyndoncx

KEUKENLUST, Everything but the kitchensink !

#5 bruyndoncx

  • Community Member
  • 2,382 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 13 July 2011, 21:48

PS I also made the banner group field a bit larger with mysql, as I ran out of characters ...
Hava a nice day !
Carine Bruyndoncx

KEUKENLUST, Everything but the kitchensink !

#6 ianhaney

  • Community Member
  • 447 posts
  • Real Name:Ian Haney
  • Gender:Male

Posted 30 July 2011, 14:01

Hello dreamingdesign

How did you get the categories to appear in a table for example when you click on the heading for example Nail Care it reveals the sub categories

I want to do that on my site, I have got oscommerce 2.3.1 installed

Can you help me and let me know how you did it please

Thank you

Ian

#7 mumme

  • Community Member
  • 121 posts
  • Real Name:magnus andersson
  • Gender:Male
  • Location:Stockholm | sweden

Posted 05 January 2012, 13:52

You can also put this code on the index page,


<?php
if ($banner = tep_banner_exists('dynamic', (int)$current_category_id)) {
?><div id="index_banner">
  <?php echo tep_display_banner('static', $banner); ?>
</div><?php
  }
?>

In the admin banner manager you just need to create a group and call it the same as the category id. Eg: 11.