VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Nelia on February 02, 2016, 12:00:43 PM

Title: show media files separate from images in productdetails
Post by: Nelia on February 02, 2016, 12:00:43 PM
Hi,
I am very new to Joomla/Virtuemart so maybe I am overlooking the obvious, but:

For each product I have one or more images and also one or more PDF-files that have additional productinformation. I used the media upload to attach all these files to a product. So now when I view the product I see all media together but I would like to set the PDF-files apart from the images on the page and I can't seem to figure out how to do this. I have found the /templates/.../html/com_virtuemart/productdetails/default.php, but can anyone give me a hand on how to query for images and pdf-files separately? I am using Joomla 3.4.8 and Virtuemart 3.0.12.
Title: Re: show media files separate from images in productdetails
Post by: PRO on February 02, 2016, 18:01:44 PM
you can actually use custom fields for this.
Just set the PDF as the custom field.

but also


default_images_additional.php


after this
   $image = $this->product->images[$i];
      add this
if ($image->file_extension =='pdf') continue;


then that will skip the pdf files


then,
you can add this code, where you want the pdf files

<div class="additional-images">
   <?php
   $start_image = VmConfig::get('add_img_main', 1) ? 0 : 1;
   for ($i = $start_image; $i < count($this->product->images); $i++) {
      $image = $this->product->images[$i];
        if ($image->file_extension !='pdf') continue;
      ?>
      <div class="floatleft">
         <?php
         if(VmConfig::get('add_img_main', 1)) {
            echo $image->displayMediaThumb('class="product-image" style="cursor: pointer"',false,$image->file_description);
            echo '<a href="'. $image->file_url .'"  class="product-image image-'. $i .'" style="display:none;" title="'. $image->file_meta .'" rel="vm-additional-images"></a>';
         } else {
            echo $image->displayMediaThumb("",true,"rel='vm-additional-images'",true,$image->file_description);
         }
         ?>
      </div>
   <?php
   }
   ?>
   <div class="clear"></div>
</div>
Title: Re: show media files separate from images in productdetails
Post by: VMTemplates.net on February 02, 2016, 18:05:20 PM
Hi,

maybe it would be easier to add only images for products (on product images tab) and PDF files add as a links in the product description. You mentioned you are very new to Joomla/VirtueMart so, if you want to avoid changes to the code this solution may work for you.
Title: Re: show media files separate from images in productdetails
Post by: Nelia on February 02, 2016, 18:53:39 PM
Hi PRO, thank you so much. This is exactly what I have been looking for for days!

Can I just ask you one more question? Can you point me towards a good reference (book, site, document?) where I can learn about the objects/functions of joomla and virtuemart? So that I can get a better understanding what the code is doing...
Title: Re: show media files separate from images in productdetails
Post by: GJC Web Design on February 03, 2016, 01:12:10 AM
One of the huge advantages of Vm2+ is that it follows standard MVC architecture as used in Joomla components

So Google any basic discussion of this code structure will inform you of how VM is put together plud investigate the actual structure.. u don't need any specific VM references  perhaps plugin structure etc

http://docs.virtuemart.net/tutorials/development.html