VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: monfil on May 04, 2012, 00:51:44 AM

Title: How to display all product images on the Category page ?
Post by: monfil on May 04, 2012, 00:51:44 AM
Hi,
(using J2.5.4/VM 2.0.6)
I have a small problem that I could not solve.
On my website, I don't use any product details page.
But I have 3 pictures for each product.
I would like to display all the product pictures on my category page.

I have created a template default_images.php in templates/mytemplate/html/com_virtuemart/category.
I can load it, but I don't know how to code to get my pictures ?

It would be nice if anyone can help  :)
Title: Re: How to display all product images on the Category page ?
Post by: AbsoluteVM on May 04, 2012, 17:51:01 PM
If you want to grab the file urls and output some thumbnails do something with a foreach mate.

In your /category/default.php whereever you want the thumbnail to appear, you can do this:

   <?php
   // List all Images
   if (count($this->product->images) > 0) {
      
       foreach ($this->product->images as $image) { // Loop through the results
      
         $ImgLink = $image->file_url;
         $ImgTitle = $this->product->product_name;
         
         echo '<a href="'.$ImgLink.'" title="'.$ImgTitle.'">'; // is it clickable?
         echo '<img src='.$ImgLink.'" alt="" title="'.$ImgTitle.'" />';
         echo '</a>';
       }
   }
   ?>
Title: Re: How to display all product images on the Category page ?
Post by: monfil on May 05, 2012, 18:23:58 PM
Hi AbsoluteVM
Thanks a lot for your answer.

I will test it and send you my feedback.
Thanks again.
Title: Re: How to display all product images on the Category page ?
Post by: PRO on May 05, 2012, 18:28:26 PM
$this->product->images

^^^ not for category

http://forum.virtuemart.net/index.php?topic=100696.0
Title: Re: How to display all product images on the Category page ?
Post by: monfil on May 06, 2012, 12:03:14 PM
Hi BT,
Thanks for your answer.
I understand this about $this-> :) and the code proposed by AbsoluteVM cannot work.
Anyway, I still don't know how to display these thumbnails in my Category page.
But I will try again  :)
Title: Re: How to display all product images on the Category page ?
Post by: SuperRat on July 03, 2013, 09:53:13 AM
I also need to display all images on category page. Any update on this?

$product->images on category page returns just the first image. I need all.

EDIT: Partially solved by editing components/com_virtuemart/cateogry/view.html.php, by replacing $productModel->addImages($products,1); with $productModel->addImages($products);

Is there a way to override this without changing core?

Thanks!