Full service web hosting, great prices and support. Starts at $1.99/month!
Results 1 to 2 of 2

Thread: Different background color for each category??

  1. #1
    surfer
    Guest


    Default Different background color for each category??

    I have 2 main categories and want to have a different background color for each and the same color for the products info.

    I can change the background via the below but don't know how to have a seperate color for each category?? Any ideas??

    catolg/template/css/stylesheet.css
    TABLE.productListing {
    background: #FFFFFF;

  2. #2
    surfer
    Guest


    Default How to do it.

    Ok, fixed this one myself. Not sure if this is perfect but I'm learning as I go and it worked nicely.

    The below changes make Oscommerce look at the Category ID and run the Stylesheet matching that Category ID. Eg: Category 3 will run Stylesheet3.css

    File: catalog/templates/*your template*/main_page.tpl.php

    Replace

    Code:
    <link rel="stylesheet" type="text/css" href="<?php echo DIR_WS_TEMPLATES; ?>stylesheet.css">
    With

    Code:
    <link rel="stylesheet" type="text/css" href="<?php echo DIR_WS_TEMPLATES; ?>stylesheet<?php echo $stylesheet_number ?>.css">

    File: catalog/includes/application_top

    Replace

    Code:
     if (tep_not_null($cPath)) {
       $cPath_array = tep_parse_category_path($cPath);
       $cPath = implode('_', $cPath_array);
       $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
     } else {
       $current_category_id = 0;
     }
    With

    Code:
     if (tep_not_null($cPath)) {
       $cPath_array = tep_parse_category_path($cPath);
       $cPath = implode('_', $cPath_array);
       $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
       $stylesheet_number = $current_category_id;
     } else {
       $current_category_id = 0;
       $stylesheet_number = '';
     }
    Now Oscommerce will look for the Stylesheet that matchs the Category number. So you will need to create stylesheet1.css, stylesheet2.css etc in catalog/templates/*your template*/

    Now you can edit each stylesheet.css file and have different category backgrounds, fonts etc.

    There's probably a cleaner way to do this but I only have 3 categories so no biggy.

Similar Threads

  1. Changing Background color
    By tclhost in forum osCmax v2 Customization/Mods
    Replies: 2
    Last Post: 11-05-2005, 02:00 PM
  2. Subcategory Background Color
    By cathelle in forum osCommerce 2.2 Modification Help
    Replies: 3
    Last Post: 08-03-2005, 08:10 AM
  3. Changing Background Color of Header
    By knowgangs in forum osCmax v1.7 Discussion
    Replies: 2
    Last Post: 07-12-2005, 11:32 AM
  4. where can I change the background color?
    By chenzhu in forum osCmax v2 Customization/Mods
    Replies: 1
    Last Post: 06-30-2005, 05:08 PM
  5. How to change categories background color?
    By javabeans in forum osCmax v1.7 Discussion
    Replies: 1
    Last Post: 04-19-2005, 04:24 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •