News:

Support the VirtueMart project and become a member

Main Menu

Changing Backround Color or Images based on Product Category selection

Started by gore, April 08, 2013, 12:11:03 PM

Previous topic - Next topic

gore

Dear All,

I am new to this forum, and Joomla development as well. Tha task required a completion is that, I would like to change the backround color or Image, based on selection of product category.
Is there any idea or technique ? Is there any other post related to this case

I am using Joomla 2.5 and VM 2.xxx

Thanks in advance
Greg

jenkinhill

You could probably do this using some JavaScript to change applied css files, or use in-line styles in template overrides which are assigned to specific categories. Not doe it myself, though, as I have never needed anything like that.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

gore

Thank you for your answer. Could you tell me what do you mean by saying "in-line styles in template overrides"? I know that it will sounds funny, but I dont have a clue about it. Actually I have 5 product manufacturers. These are shown in a list box. The task is, when select Prada or Dolce & Gabbana manufacturer change the backround image.

I had checked Product Categories or Manufacturers and I can not find something in order to set stylesheet. \

These that you mentioned before is a property? (in-line styles in template overrides)

Tnks 


gore

Actually I did not understand what you meant. I have the code below

   <!-- Selector Module -->
<?php echo $text_before ?>
<form action="<?php echo 'index.php?option=com_virtuemart' ?>" method="post">
   <font color="#000000"><b> Επιλογή Brand </b></font>
   <?php echo JHTML::_('select.genericlist', $manufacturers, 'virtuemart_manufacturer_id', 'class="inputbox" onchange="this.form.submit()"','virtuemart_manufacturer_id',  'mf_name', 1 ) ; ?>
<input type="hidden" name="view" value="manufacturer"/>
</form>
------------------------------------------------------------------------------------------
The think that I want is, for example by selecting something from virtuemart_manufacturer_id to change the backround colour .
Where do I have to put the code

Thanks again fro your time

PRO

Quote from: gore on April 09, 2013, 16:06:50 PM
Actually I did not understand what you meant. I have the code below

   <!-- Selector Module -->
<?php echo $text_before ?>
<form action="<?php echo 'index.php?option=com_virtuemart' ?>" method="post">
   <font color="#000000"><b> Επιλογή Brand </b></font>
   <?php echo JHTML::_('select.genericlist', $manufacturers, 'virtuemart_manufacturer_id', 'class="inputbox" onchange="this.form.submit()"','virtuemart_manufacturer_id',  'mf_name', 1 ) ; ?>
<input type="hidden" name="view" value="manufacturer"/>
</form>
------------------------------------------------------------------------------------------
The think that I want is, for example by selecting something from virtuemart_manufacturer_id to change the backround colour .
Where do I have to put the code

Thanks again fro your time


background color of the module? or the whole page?


gore

I want to change the backround either the color or the image. It depends on what is the best suitable and shown

PRO



PRO



to do the whole webpage,

this will go in your template


This is the php function
it works with manufacturer id, & category id

        <?php function vPageClass(){
        if ( JRequest::getInt('virtuemart_category_id') !=0){
        $class='c'.JRequest::getInt('virtuemart_category_id');
        }
        elseif ( JRequest::getInt('virtuemart_manufacturer_id') !=0){
         $class='m'.JRequest::getInt('virtuemart_manufacturer_id');
        }
        return $class;
        }?>


THEN: in your <body tag>

You have to add this
<?php echo vPageClass() ?>

Here is an example, of how I just tested this on my site

<body class="blue firefight <?php echo vPageClass() ?>" id="firefight">



THEN:

what that does is add a class like

c12   to the body, When the category id is 12.
if you were viewing category id 25, it would be    c25

The same with the manufacturer ID, BUT   is    m12, and m25


THEN,


You will have to add the css to your template css file , then you can choose the color you want etc.


I sure hope you can figure it out from here

&& ofcourse, you should backup any file before editing it