Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Code: Select all
<div class="col-md-12 tff-cuzt-col">
    <cms:pages masterpage='products.php' page_name="<cms:show k_page_name />">
    <cms:set my_buffer='0''global'/>
    <cms:capture into='my_buffer'>
    <cms:fieldset label='Customization' class='tff-checkbox'>
     <cms:input type="checkbox"
                       name="customize_items"
                       label='Select the items you wish'
                       opt_values="<cms:show_repeatable 'customize' startcount='0'> | <cms:show desc_headin />:&nbsp;
                       <cms:show desc_item /><cms:set my_buffer='1''global'/></cms:show_repeatable>"/>
                       
    </cms:fieldset>
    </cms:capture>
    <cms:if my_buffer>
    <cms:fieldset label='Customization' class='tff-checkbox'>
     <cms:input type="checkbox"
                       name="customize_items"
                       label='Select the items you wish'
                       opt_values="<cms:show_repeatable 'customize' startcount='0'> | <cms:show desc_headin />:&nbsp;
                       <cms:show desc_item /></cms:show_repeatable>"/>
    </cms:fieldset>
    </cms:if>
    </cms:pages>
    </div>

I've been trying to hide the whole fieldset if there is not value in the reapetable desc_item... This code works but fieldset still shows even when the desc_item value is empty in some cloned pages.

products.php has cloned pages. each page has a repeatable field which has desc_heading and desc_item. I dont want to show the fieldset if there is no value added to the input desc_item.

What am I doing wrong here?
At simplest, you are using the same name for variable that holds checkbox options and a variable that flags if desc_item is set. Both different in meaning variables have the same name 'my_buffer' and essentially code rewrites the value of this variable, which is not correct.
Please try following piece, completely replacing posted code.
Code: Select all
<cms:set desc_item_exists = '0' scope='global' />
<cms:capture into='checkbox_values' >
    <cms:show_repeatable 'customize' startcount='0'>
        | <cms:show desc_heading />:&nbsp;
          <cms:show desc_item />
          <cms:if desc_item >
              <cms:set desc_item_exists = '1' scope='global' />
          </cms:if>
    </cms:show_repeatable>
</cms:capture>

<cms:if desc_item_exists >
    <div class="col-md-12 tff-cuzt-col">
        <cms:fieldset label='Customization' class='tff-checkbox'>
             <cms:input type="checkbox"
                               name="customize_items"
                               label='Select the items you wish'
                               opt_values=checkbox_values />
                               
        </cms:fieldset>
    </div>
</cms:if>   

P.S. I used 'desc_heading' instead of 'desc_headin'. Please make sure you use the correct name of editable field, if I fixed it erroneously.
trendoman wrote: At simplest, you are using the same name for variable that holds checkbox options and a variable that flags if desc_item is set. Both different in meaning variables have the same name 'my_buffer' and essentially code rewrites the value of this variable, which is not correct.
Please try following piece, completely replacing posted code.
Code: Select all
<cms:set desc_item_exists = '0' scope='global' />
<cms:capture into='checkbox_values' >
    <cms:show_repeatable 'customize' startcount='0'>
        | <cms:show desc_heading />:&nbsp;
          <cms:show desc_item />
          <cms:if desc_item >
              <cms:set desc_item_exists = '1' scope='global' />
          </cms:if>
    </cms:show_repeatable>
</cms:capture>

<cms:if desc_item_exists >
    <div class="col-md-12 tff-cuzt-col">
        <cms:fieldset label='Customization' class='tff-checkbox'>
             <cms:input type="checkbox"
                               name="customize_items"
                               label='Select the items you wish'
                               opt_values=checkbox_values />
                               
        </cms:fieldset>
    </div>
</cms:if>   

P.S. I used 'desc_heading' instead of 'desc_headin'. Please make sure you use the correct name of editable field, if I fixed it erroneously.


Thanks a lot @trendoman, this worked, and thanks for the explanation.!
3 posts Page 1 of 1

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 1 guest