Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
@KK Sir,
I am having multiple images for a product in a site that I am doing. I am using the CouchCart, which requires the pp_product_thumb editable. I am unable to display the thumbnail on the cart page; at all other locations (page view and list view) of the product I am able to display the image(s).

My Editable is defined as:
Code: Select all
<cms:editable name="setting_prod_image" label="Setting: Product Images" type="group" order="2" />
       <cms:mosaic name='prod_images' label='Images' group="setting_prod_image" order="1">
          <cms:tile name='image' label='Image'>
               <cms:editable name="prod_images_display" label="Main Image" type="image" show_preview="1" preview_width="100" order="1" />
            <cms:editable name='pp_product_thumb' label='Thumbnail' width='70' show_preview='1' assoc_field='prod_images_display' type='thumbnail' order='2' />
          </cms:tile>
       </cms:mosaic>   


Then to display the image from mosaic on the cart page i have the following code:
Code: Select all
<cms:show_mosaic "prod_images" >
   <cms:if k_tile_name='image'>
      <img src='<cms:show pp_product_thumb />' width='70' height='64' alt='<cms:show k_page_title />' />
   </cms:if>
</cms:show_mosaic>


But the image does not appear on the cart page.

On the backend the mosaic is displayed as:
couchcms-mosaic-cart.png
couchcms-mosaic-cart.png (27.78 KiB) Viewed 1632 times


How can the thumbnail be displayed on the cart page?

Regards,
GenXCoders
Image
where innovation meets technology
Hi,

Before I come to the proposed solution, I need to say this -
I see that your mosaic has only a single tile; if indeed that is the way you are using it (i.e. the code you posted is not abridged), then, IMHO, it'd be better to simply use repeatable region (with two fields).

Anyway, moving on to the solution -
I am sure you are using <cms:pp_cart_items> to show the cart items. As mentioned in the docs (https://docs.couchcms.com/concepts/shopping-cart-1.html), this tag fetches some predefined fields from each cart item (e.g. id, name, title, link etc.) and also, as a convenience, all fields prefixed with 'pp_'.

Since the mosaic field doesn't fit into either of the two categories, it is not present in the cart.
To fetch it there, you can use the 'id' or 'name' made available by the cart for each cart item to explicitly get to the field in question.
One way could be this (the other is <cms:pages> of course) -
Code: Select all
<cms:get_field 'images' masterpage='your_product_template.php' page=name >
    <cms:show_mosaic "prod_images" >
        <cms:if k_tile_name='image'>
            <img src='<cms:show pp_product_thumb />' width='70' height='64' alt='<cms:show k_page_title />' />
        </cms:if>
    </cms:show_mosaic>
</cms:get_field>

Please make sure to specify the correct template name for 'masterpage' above.

Hope this helps.
@KK Sir,
Good evening!

Sir I had used the repeatable region earlier. But then I was unable to use <cms:thumbnail> for the pp_product_thumb. As I have a variety of thumbnails at different locations to use, I used the <cms:thumbnail> tag and set the width and height as per required.

Do you suggest to revert back to the repeatable region and use the <cms:get_field> tag from a better coding perspective?

Regards,
GenXCoders
Image
where innovation meets technology
I think it'd be better now to continue with your mosaic based solution.
Please test the fix I suggested and let me know it it helps,
@KK Sir,

I will implement it and get back.

Regards,
GenXCoders
Image
where innovation meets technology
@KK Sir,
I have tried the code shared by you:
Code: Select all
<cms:get_field 'images' masterpage='your_product_template.php' page=name >
    <cms:show_mosaic "prod_images" >
        <cms:if k_tile_name='image'>
            <img src='<cms:show pp_product_thumb />' width='70' height='64' alt='<cms:show k_page_title />' />
        </cms:if>
    </cms:show_mosaic>
</cms:get_field>


In my case:
your_product_template.php = product.php


The code works well when I use it as:
Code: Select all
<cms:get_field 'images' masterpage='your_product_template.php' page=name >
    <cms:show_mosaic "prod_images" >
        <img src='<cms:show pp_product_thumb />' width='70' height='64' alt='<cms:show k_page_title />' />
    </cms:show_mosaic>
</cms:get_field>


But if I use the condition:
Code: Select all
<cms:if k_tile_name='image'>

The image is not displayed. It took time for me to remove the cms:if and check. So replied late.

If I use the code you suggested, without the <cms:if> statement, it is working well.

Regards,
GenXCoders
Image
where innovation meets technology
6 posts Page 1 of 1
cron