Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I have 2 templates that are identical in terms of structure (one page is a menu and the other is catering menu). I am trying to hide a div if there is not an image uploaded. The code works perfectly on the menu page, but hides everything on the catering menu page. I am not sure why it works on one and not the other. Any idea where I am going wrong?

Code: Select all
<cms:pages masterpage='catering-menu.php' order='asc'>
                  <div class="menu-list">
                     <div class="menu-title cute-12-tablet text-center">
                        <h2><cms:show k_page_title /></h2>
                        <h2 class="head-title"><cms:show sub_title /></h2>
                     </div>
                     <cms:capture into='cm_buffer'>
                        <cms:show_repeatable 'menu'>
                           <div class="menu-details cute-6-tablet">
                              <h2><cms:show item_name /> - <cms:show item_price /> <span></span></h2>
                              <p>
                                 <cms:show item_desc />
                              </p>
                              <cms:if "<cms:not_empty item_img />">
                                 <a href="<cms:show item_img />" class="menu-link mag-pop" title="<cms:show item_name />">
                                    <i class="fa fa-camera"></i> SEE WHAT IT LOOKS LIKE!
                                 </a>
                                 <cms:set show_buffer='1' 'global' />
                              </cms:if>
                           </div>
                        </cms:show_repeatable>
                     </cms:capture>
                     <cms:if show_buffer ><cms:show cm_buffer /></cms:if>

                  </div><!-- end Menu list -->
               </cms:pages>
Hi Jon,

I assume you want to hide the '<div class="menu-details cute-6-tablet">' DIV if there is no image in that row. Correct?

If so, the right code should be as follows -
Code: Select all
<cms:show_repeatable 'menu'>

    <cms:set show_buffer='0' 'global' />
   
    <cms:capture into='cm_buffer'>
        <div class="menu-details cute-6-tablet">
          <h2><cms:show item_name /> - <cms:show item_price /> <span></span></h2>
          <p>
             <cms:show item_desc />
          </p>
          <cms:if "<cms:not_empty item_img />">
             <a href="<cms:show item_img />" class="menu-link mag-pop" title="<cms:show item_name />">
                <i class="fa fa-camera"></i> SEE WHAT IT LOOKS LIKE!
             </a>
             <cms:set show_buffer='1' 'global' />
          </cms:if>
       </div>
   </cms:capture>
   
   <cms:if show_buffer ><cms:show cm_buffer /></cms:if>
   
</cms:show_repeatable>

In fact, for this particular case you don't need to buffer the output at all. It can simply be handled as follows -
Code: Select all
<cms:show_repeatable 'menu'>
    <cms:if "<cms:not_empty item_img />">
        <div class="menu-details cute-6-tablet">
            <h2><cms:show item_name /> - <cms:show item_price /> <span></span></h2>
            <p>
                <cms:show item_desc />
            </p>
            <a href="<cms:show item_img />" class="menu-link mag-pop" title="<cms:show item_name />">
                <i class="fa fa-camera"></i> SEE WHAT IT LOOKS LIKE!
            </a>
        </div>
    </cms:if>
</cms:show_repeatable>

Does it help?
Hi KK,

The second option worked perfectly. Thank you!
3 posts Page 1 of 1