O
O
Oleh Lantukh2020-09-11 21:29:27
MODX
Oleh Lantukh, 2020-09-11 21:29:27

How to display multiple images in a catalog product card using the msProducts snippet?

I have a list of products in the catalog through the msProducts snippet

{$_modx->runSnippet('msProducts', [
          'parents' => 5,
          'includeThumbs' => 'middle,retinamiddle',
          'tpl'=> '@FILE chunks/product.tpl'
          ])}


In the product card, you need to display all the pictures from the gallery.
To do this, in the chunk (product.tpl) I run the msGallery snippet
<li>
  <h3>{$pagetitle}</h3>
    <figure>
      {$_modx->runSnippet('msGallery', [
      'product' => $id,
      'tpl'=> '@FILE chunks/middle_images.tpl'
      ])}
    </figure>
</li>


Chunk (middle_images.tpl) with pictures looks like this
{foreach $files as $file}
    <img src="{$file['middle']}" srcset="{$file['retinamiddle']} 2x">
{/foreach}


It turns out that at the output of each product there is an additional request to receive pictures.
Is there a way to immediately get all the pictures without making an extra request?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question