Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
Code: Select all
 <div class="li-col">
                    <cms:pages masterpage='products.php' folder=k_folder_name skip_custom_fields='1' >
                  <li><a href="<cms:show k_page_link />"  data-toggle="modal" data-target="#prod-modal" class="gffproductlinka"><cms:show k_page_title /></a>
                    <br>
                    <div id="imgdiv"></div>
                  </li>
                  </cms:pages>
                </div>


Hi guys, can someone help me with the code above, this is a part of the code, where pages are listed from a specific folder.

What I'm trying to do here is display an image from that unique post, when I hover the <li>.
The <li>'s are populated with products.php it has a repeated images field, I want to just display one image from those, inside the id="imgdiv".

I've tried bootstrap tooltip and tried appending images with jquery too. But couldn't grab the image from the post.
Hi Cosmicmind,

Assuming you are using the latest beta version of Couch (2.1) you could use

Code: Select all
<cms:get_field 'product_images' masterpage='products.php'  page=k_page_name >
     <cms:show_repeatable k_field_name >
          <cms:if k_first_row>
               <div class='imgdiv'>
                    <img src="<cms:show product_image/>" alt="<cms:show product_name/>"/>
               </div>
          </cms:if>
     </cms:show_repeatable>
</cms:get_field>


Note that I have changed the div ID from imgdiv and used classes instead. DOM ID are supposed to be unique so it is a missue of IDs to use the same ID for each product on the same page.

If you are not using couch 2.1, there is another solution.

Code: Select all
<cms:pages masterpage='products.php' folder=k_folder_name >
     <cms:show_repeatable product_images >
          <cms:if k_first_row>
               <div class='imgdiv'>
                    <img src="<cms:show product_image/>" alt="<cms:show product_name/>"/>
               </div>
          </cms:if>
     </cms:show_repeatable>
</cms:pages>


Note that skip_custom_fields has been removed
2 posts Page 1 of 1
cron