Jump to content



Latest News: (loading..)

- - - - -

Sub-Category Banner


  • Please log in to reply
12 replies to this topic

#1   dreamingdesign

dreamingdesign
  • Members
  • 1 posts
  • Real Name:Stephane Masetto

Posted 11 July 2011 - 08:34 AM

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

bruyndoncx

    Problem Thinker

  • Members
  • 2,656 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 11 July 2011 - 12:13 PM

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


P.S. if you found me helpfull, would you help me and try out my shop on your device (phone, tablet, laptop, desktop, tv)
and let me know how it went in my responsive liive shop review thread ?

PS2
Did you know 99% of all people benefiting from my posts, won't bother to repay the favor.
Wouldn't it be great if you are part of that exclusive 1% ?
Now, head over to www.keukenlust.be and post your findings in my responsive liive shop review thread ?

#3   wendy_purple

wendy_purple
  • Members
  • 12 posts
  • Real Name:Wendy
  • Gender:Female

Posted 13 July 2011 - 12:18 AM

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

#4   bruyndoncx

bruyndoncx

    Problem Thinker

  • Members
  • 2,656 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 13 July 2011 - 09:47 PM

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


P.S. if you found me helpfull, would you help me and try out my shop on your device (phone, tablet, laptop, desktop, tv)
and let me know how it went in my responsive liive shop review thread ?

PS2
Did you know 99% of all people benefiting from my posts, won't bother to repay the favor.
Wouldn't it be great if you are part of that exclusive 1% ?
Now, head over to www.keukenlust.be and post your findings in my responsive liive shop review thread ?

#5   bruyndoncx

bruyndoncx

    Problem Thinker

  • Members
  • 2,656 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 13 July 2011 - 09:48 PM

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


P.S. if you found me helpfull, would you help me and try out my shop on your device (phone, tablet, laptop, desktop, tv)
and let me know how it went in my responsive liive shop review thread ?

PS2
Did you know 99% of all people benefiting from my posts, won't bother to repay the favor.
Wouldn't it be great if you are part of that exclusive 1% ?
Now, head over to www.keukenlust.be and post your findings in my responsive liive shop review thread ?

#6   ianhaney

ianhaney
  • Members
  • 851 posts
  • Real Name:Ian Haney
  • Gender:Male

Posted 30 July 2011 - 02:01 PM

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

mumme
  • Validating
  • 121 posts
  • Real Name:magnus andersson
  • Gender:Male
  • Location:Stockholm | sweden

Posted 05 January 2012 - 01:52 PM

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.

#8   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 24 July 2012 - 04:31 PM

View Postmumme, on 05 January 2012 - 01:52 PM, said:

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.

Hi Mumme!

1st of all, this is a fabulous tip! It doesn't seem to be working for subcategories though (eg 31_3)...
Is there a way to get this to work for subcategories as well?

#9   kymation

kymation

    Believers

  • Community Sponsor
  • 6,686 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 24 July 2012 - 06:03 PM

$current_category_id is valid for every category, no matter what the level. Make sure your banner group is just the category ID number, not the cPath (e.g. 235 not 21_56_235).

Regards
Jim
My Addons

Banners Box 2.3.x  Support
Categories Accordion Box 2.3.x  Support
Categories Images Box 2.2x  2.3.x  Support
Closest Shipper 2.2x  Support
Document Manager 2.2x  Support
Generic Box 2.3.x  Support
Get 1 Free 2.2x  Support
jQuery Banner Rotator 2.2x  2.3.x  Support
Modular Front Page 2.3.x  Support
Modular SEO Header Tags 2.3.x  Support
MVS 2.2x  Support
PDF Datasheet 2.3.x  Support
Price Updater 2.2x
Products Specifications 2.2x  2.3.x  Development Version  Support  Bugs/Suggestions
Request a Review 2.2x - 2.3.x  Support
Similar Products Box 2.2x
Specials Image Overlay 2.3x Support
Theme Switcher 2.3.x  Support

#10   bruyndoncx

bruyndoncx

    Problem Thinker

  • Members
  • 2,656 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 24 July 2012 - 06:03 PM

have you tried just with "3" ?
it is based on the categories_id, not the full path.
Hava a nice day !
Carine Bruyndoncx


P.S. if you found me helpfull, would you help me and try out my shop on your device (phone, tablet, laptop, desktop, tv)
and let me know how it went in my responsive liive shop review thread ?

PS2
Did you know 99% of all people benefiting from my posts, won't bother to repay the favor.
Wouldn't it be great if you are part of that exclusive 1% ?
Now, head over to www.keukenlust.be and post your findings in my responsive liive shop review thread ?

#11   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 26 July 2012 - 01:21 PM

Hi guys, I tried just using the categories id, but that didn't work.
I decided to go with the categories description addon.
This way I add text and images to categories as well as subcategories ;)

#12   14steve14

14steve14

    STORE OWNER NOT CODER

  • Members
  • 3,074 posts
  • Real Name:Steve
  • Gender:Male
  • Location:Dorset UK

Posted 26 July 2012 - 03:16 PM

Try installing headertags_seo. This will help with many aspects of seo withing your site, and will allow you to add text to each category and subcategory, which also means that you can use html to add images.
REMEMBER BACKUP, BACKUP AND BACKUP
I am not a coder, so dont bother sending PMs asking for help as you wont get any.  

OSC has a steep learning curve, but in general the program does work.  If it doesnt work, the chances are it is something you have done.

#13   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 04 August 2012 - 08:56 PM

Thanks for the tip Steve! I allready have SEO URLS 5 installed though...