View Single Post
  #8  
Old 07-30-2014, 05:10 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Different background color for each category

Hi!

So, here is what you need to do:
1) Create an empty module as described here: http://kb.x-cart.com/display/XDD/How+to+create+a+module

Don't forget to adjust namespace according to your developer and module ID!

2) Put the Controller/Category.php file inside your module with the following content:

PHP Code:
<?php

namespace XLite\Module\XC\CustomSkin\Controller;

class 
Category extends \XLite\Controller\Customer\Category implements \XLite\Base\IDecorator
{
    public function 
defineBodyClasses(array $classes) {
        
$classes parent::defineBodyClasses($classes);

        if (
$this->getCategory()->getId() == 2) {
            
$classes[] = 'category-number-2';
        }

        return 
$classes;
    }
}

Again, do not forget to change the namespace!

This code will add category-number-2 class to body element if category ID is 2.

3) Add CSS file that will apply your own style to the <body> elements according to your preference. It is described here: http://kb.x-cart.com/display/XDD/Adding+new+CSS+file

Please, let me know this helps.

Tony.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote