Author Topic: multiple images in the category view  (Read 261 times)

caesarsk

  • Beginner
  • *
  • Posts: 33
multiple images in the category view
« on: July 03, 2018, 13:39:44 pm »
Hi all,

in older versions of VM I had made showing second image in the category view.
code:
Code: [Select]
if(isset($product->images[1])){
echo $product->images[0]->displayMediaThumb('class="browseProductImage MoreImg"', false);
echo $product->images[1]->displayMediaThumb('class="browseProductSecondImage"', false);
} else {
echo $product->images[0]->displayMediaThumb('class="browseProductImage theOne"', false);
}

but in new versions this code not working. $product->images return only one image.

my question.
$product->virtuemart_media_id return all media resorces. But how should I do this so that the function displayMediaThumb returns a thumb link?
I try luck with $product->virtuemart_media_id[1]->displayMediaThumb('class="browseProductSecondImage"', false);, but this no work.

I know how to make it "drastically", but I'd like to have it sorted out nicely. If it does.

any idea?

caesarsk

  • Beginner
  • *
  • Posts: 33
Re: multiple images in the category view
« Reply #1 on: July 03, 2018, 18:59:05 pm »
here is not nice solution, but for me is quick and works.
1. override template com_virtuemart/sublayouts/products.php
2. paste function on beginning of the file (function return link to thumb of second image):
Code: [Select]
function secondImage ($id_1,$file_0_title,$thumb_path,$thumb_0_title){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName('file_title'))
->from($db->quoteName('#__virtuemart_medias'))
->where($db->quoteName('virtuemart_media_id') . " = '" . $id_1 . "'")
->setLimit('1');
$db->setQuery($query);
$result = $db->loadResult();

$explode_title_0 = explode('.',$file_0_title);
$suffix = str_replace($explode_title_0[0],"",$thumb_0_title);
$explode_title_1 = explode('.',$result);

$link_1 = $thumb_path . $explode_title_1[0] . $suffix . '.' . $explode_title_1[1];
return($link_1);
}

3. add <img src=""> tag, for example like this:
Code: [Select]
// this is original VM thumb
echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);

// this is second image
echo '<img src="'. secondImage($product->virtuemart_media_id[1],$product->images[0]->file_title,$product->images[0]->file_url_folder_thumb,$product->images[0]->file_name_thumb) . '" class="browseProductSecondImage">';

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3154
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: multiple images in the category view
« Reply #2 on: July 03, 2018, 20:33:19 pm »
You can use VM core, add in your file JOOMLAROOT\administrator\components\com_virtuemart\virtuemart.cfg
prodimg_browse=2

then 2 images are loaded and you can use
                  <?php
                  echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);
                  ?>
                  <?php
                  if(!empty($product->images[1] ))
                     echo $product->images[1]->displayMediaThumb('class="browseProductImage"', false);
                  ?>

caesarsk

  • Beginner
  • *
  • Posts: 33
Re: multiple images in the category view
« Reply #3 on: July 03, 2018, 21:49:38 pm »
yop, this is elegant solution. but update rewrite this, right?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3154
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: multiple images in the category view
« Reply #4 on: July 03, 2018, 22:59:54 pm »
No, if you do an overrdie in your template folder, then the PHP code is not modified on Virtuemart Update.
virtuemart.cfg is never modified as i know you have a virtuemart.default.cfg used on install firts time.
But you need to edit VM config and save, so the settings get saved in the Vm config table.

caesarsk

  • Beginner
  • *
  • Posts: 33
Re: multiple images in the category view
« Reply #5 on: July 03, 2018, 23:26:35 pm »
perfect, thx very much

caesarsk

  • Beginner
  • *
  • Posts: 33
Re: multiple images in the category view
« Reply #6 on: July 03, 2018, 23:32:48 pm »
doesnt work :(

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3154
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: multiple images in the category view
« Reply #7 on: July 04, 2018, 00:02:35 am »
Your VM release is ?
Have you try using protostar ?

caesarsk

  • Beginner
  • *
  • Posts: 33
Re: multiple images in the category view
« Reply #8 on: July 04, 2018, 07:44:05 am »
I have own template. VM 3.2.14

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3154
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: multiple images in the category view
« Reply #9 on: July 04, 2018, 11:07:57 am »
try to print_r($product->images);