So I have one more thing here... Lets say I only have like 5 products on a whole shop but I really need every one of them to be well designed. Is there a way to use a different background color for each product? Didn't find such a thing here on forum...
Iam on latest Joomla and latest VM
for category page?
sublayouts/products.php
change this
// Show Products ?>
<div class="product vm-col<?php echo ' vm-col-' . $products_per_row . $show_vertical_separator ?>">
to this
// Show Products ?>
<div class="color<?php echo $product->virtuemart_product_id ?> product vm-col<?php echo ' vm-col-' . $products_per_row . $show_vertical_separator ?>">
then you will have a class set for each product
.colorTHE_PRODUCT_ID
Then just style it in your style sheet like you want.
OK great :) - one question though. I am not really sure how sublayouts work but - if I change anything in it - does the update overwrite it?
Quote from: PRO on August 21, 2018, 21:07:10 PM
for category page?
Nah not really - I need to be able to change is on a product detail page - the whole page background.
same idea but on the over ridden product details template
So this doesn't work. It always adds "color" to a class but no ID behind it :-(
I should add that I cannot add this to a product details because I need to adjust the whole background on a whole product page so I added this as a body class to my template index.php. But it wasnt working in product description as well. I always adds only COLOR which means its unable to understand this: <?php echo $product->virtuemart_product_id ?>
It should work in sublayout products.php. You must be in the right context. Within this for example:
foreach ( $products as $product ) {
Otherwise $product may be meaningless.
use
print_r($product);
to see the contents of product.
Jörgen @ Kreativ Fotografi
Well I used another approach. But thank you guys cause this thread help me to understand how to proceed.
What I did was this - each product has a unique url so I did this:
color<?php if(strpos($_SERVER['REQUEST_URI'], 'productname') !== false):?>productname<?php else: ?><?php endif; ?>
Quote from: Jack Stiles on August 22, 2018, 16:22:02 PM
color<?php if(strpos($_SERVER['REQUEST_URI'], 'productname') !== false):?>productname<?php else: ?><?php endif; ?>
One of the poorest code i have see!
<div class="color<?php echo $this->product->virtuemart_product_id ?>" >
if your on details
Quote from: Studio 42 on August 22, 2018, 22:59:02 PM
One of the poorest code i have see!
Well thank you for letting me know it was really helpful :o
Jack, i think this helps you.
You have solution using virtuemart product id, this is set in all case when you show a product.
IF you need to use it in the template directly and not in virtuemart, you can get it from the input query.
see in general for joomla https://docs.joomla.org/Retrieving_request_data_using_JInput
in your case :
<?php
$jinput = JFactory::getApplication()->input;
$id= $jinput->getInt('virtuemart_product_id',null);
if(empty($id)) $id='';
?>
<div class="color<?php echo $id ?>">
Quote from: Studio 42 on August 23, 2018, 10:25:31 AM
Jack, i think this helps you.
You have solution using virtuemart product id, this is set in all case when you show a product.
Thanks! Works as a charm! ;)