VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: EvanGR on June 01, 2020, 13:21:05 PM

Title: Override VM assets in template?
Post by: EvanGR on June 01, 2020, 13:21:05 PM
Hello,

I had replaced some images in here:

/components/com_virtuemart/assets/images/availability

but it seems a VM update restored the default files.

Can I override these in my template instead, to avoid future issues? If so, how would I structure the path relative to the template?

Thanks!
Title: Re: Override VM assets in template?
Post by: AH on June 01, 2020, 17:41:58 PM
Yes it is annoying - I had to be careful of this every time

NOTE that if you have category based template overrides - this will not work for you

You can store your availability images in /yourtemplate/images/availability
When you do this the product admin function looks for /yourtemplate/images/availability

If it finds it, it uses this for the config of products - BUT VM just does not carry this option through into the FE views !!


So stick you availability images in the template folder as shown above:
/yourtemplate/images/availability

Then use the available shopfunctions to determine if there is an availability images folder in your FE template 

By doing this to any place where you display FE availability images:-


$vmtemplate = VmTemplate::loadVmTemplateStyle();
$availabilityImagePath = shopFunctions::getAvailabilityIconUrl($vmtemplate);


Now you have the place where your template images are configured from in the FE

So just edit the display of the image:

From

if (!empty($this->product->product_availability)) { ?>
<div class="availability">
<?php echo (file_exists(JPATH_BASE $availabilityImagePath $product->product_availability)) ? JHtml::image(JURI::root() . $availabilityImagePath $product->product_availability$product->product_availability, array('class' => 'availability')) : vmText::_($product->product_availability); ?>
</div>


to


<?php
if (!empty($this->product->product_availability)) { ?>

<div class="availability">
<?php echo JHtml::image(JURI::root().$availabilityImagePath.$this->product->product_availability$this->product->product_availability, array('class' => 'availability')); ?>
</div>
<?php ?>


I have asked the team to look into this
Title: Re: Override VM assets in template?
Post by: EvanGR on June 02, 2020, 09:04:07 AM
Thank you very much for the detailed reply. I was hoping for a simple answer, I hope this gets sorted soon.

Title: Re: Override VM assets in template?
Post by: AH on June 02, 2020, 10:29:30 AM
I dont think it is a priority!  So dont hold your breath.