Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
hi kk,

im here again. i wondering whats is wrong with my code.
i have a product to list in the main page. thus i create a clonable template name application.php
here is the code

Code: Select all
<?php require_once ('admin/cms.php') ; ?>
   <cms:template title="application" clonable='1'>
      <cms:editable type='image' name='appPhoto' label='application Image'/>
      <cms:editable type="richtext" name='desc' label='Application description' />
   </cms:template >


<?php COUCH::invoke(); ?>


i am going to list all the product in main page called index.php
here is the code
Code: Select all
<cms:pages masterpage="application.php">
            <div class="col-lg-4">
               <img src="<cms:show appPhoto />" alt="" class="img-circle">
                  <h2><cms:show k_page_title /></h2>
                  <p class="product-content">
                     <cms:excerptHTML count='25' ignore='img'> <cms:show desc /> </cms:excerptHTML>
                  </p>

                  <!-- Button trigger modal -->
               <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
                 See Product
               </button>

               <!-- Modal -->
               <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                 <div class="modal-dialog">
                   <div class="modal-content">
                     <div class="modal-header">
                       <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                       <h4 class="modal-title" id="myModalLabel"> <cms:show k_page_title /> </h4>
                     </div>
                     <div class="modal-body">
                       <p>
                          <cms:show desc />
                       </p>
                     </div>
                     <div class="modal-footer">
                       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                     </div>
                   </div>
                 </div>
               </div>
            </div><!--end of col 4 -->
         </cms:pages>


the problem is all my modal has the same content(last product listed) not the respective product.

something that i do wrong?

thanks for your help.
Hi Billy,

As the cms:pages tag loops through the fetched pages, you are setting the same CSS ID for each generated modal window -
button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">

<!-- Modal -->
<div class="modal fade" id="myModal"

You need to give a unique ID to each modal. I think if you make the following changes, things should work -
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal<cms:show k_count />">

<!-- Modal -->
<div class="modal fade" id="myModal<cms:show k_count />"

Hope this helps.
2 posts Page 1 of 1