News:

Support the VirtueMart project and become a member

Main Menu

How to display all product images on the Category page ?

Started by monfil, May 04, 2012, 00:51:44 AM

Previous topic - Next topic

monfil

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  :)

AbsoluteVM

#1
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>';
       }
   }
   ?>

monfil

Hi AbsoluteVM
Thanks a lot for your answer.

I will test it and send you my feedback.
Thanks again.

PRO


monfil

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  :)

SuperRat

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!