Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
I am trying to hide and unhide a section on my website with couch if statements and am not able to figure out where I am going wrong.

Here are the editable regions:
Code: Select all
<cms:editable name='testimonial_enable' label='Enable Testimonial' opt_values='Enable=1 || Disable=0' type='radio' group='product_testimonial' order='9'/>
   <cms:repeatable name='product_testimonials' label='Testimonials' required='0' group='product_testimonial'>
      <cms:editable name='testimonial_name' label='Name' required='0' type='text' group='product_testimonial' order='2'/>
      <cms:editable name='testimonial_quote' label='Quote' required='0' type='textarea' group='product_testimonial' order='3'/>
   </cms:repeatable>


Here is the section I am trying to hide/show:
Code: Select all
<cms:if "<cms:get_custom_field 'testimonial_enable' masterpage='store.php'/>">
   <section class="section">
      <div class="container-fluid">
         <div class="section-header">
            <h1>
               Customer <small class="light">Testimonials</small>
            </h1>
         </div>
         <div class="row-fluid">
            <div class="tabbable tab-pills span12">
               <ul class="nav nav-pills nav-stacked span2">
               <cms:show_repeatable 'product_testimonials' >
                  <li <cms:if k_count = '1'>class="active"</cms:if>>
                     <a data-toggle="tab" href="#pill-tab<cms:show k_count/>"><cms:show testimonial_name/></a>
                  </li>
               </cms:show_repeatable>
               </ul>
               <div class="tab-content span10">
               <cms:show_repeatable 'product_testimonials' >
                  <div class="tab-pane <cms:if k_count = '1'>active</cms:if>" id="pill-tab<cms:show k_count/>">
                     <h3><cms:show testimonial_name/> Testimonial</h3>
                     <p><cms:show testimonial_quote/></p>
                  </div>
               </cms:show_repeatable>
               </div>
            </div>
         </div>
      </div>
   </section>
</cms:if>
Your code seems to be fine.
Please make sure to hit 'save' on all cloned pages for the selected value to get saved (that is to say, just by defining the radio button won't give any value to the field - you'll also have to save the pages).

Hope this helps.
Thanks KK, but I have saved all pages and it still doesn't want to hide. It always shows on the page. Any other ideas of what I could be missing?
That is strange as your code is working well for me.

Let us do a bit of debugging - please put just the following somewhere on the page
Code: Select all
<h1> Enabled is: <cms:get_custom_field 'testimonial_enable' masterpage='store.php'/></h1>

See what is being outputted. With 'Disabled' selected, you should see 'Enabled is: 0'. The '0' is important. If you can see 0, the cms:if block should not execute thus hiding the enclosed content.

Please let me know.
I am getting a 1 whether it is enabled or disabled.
Given that the repeatable region (product_testimonials) is already utilized directly (appears not to be nested within a cms:pages block), you shouldn't need to use get_custom_field; testimonial_enable should already be provided. Try change your condition from -
Code: Select all
<cms:if "<cms:get_custom_field 'testimonial_enable' masterpage='store.php'/>">
to -
Code: Select all
<cms:if testimonial_enable>
Don't forget that you can always just drop in <cms:dump/> to see what values are available.
That worked perfectly. What would I do without you cheesypoof ;)
@cheesypoof, any idea why cms:get_custom_field did not work? It was, as you correctly pointed out, redundant in this case but nevertheless should have worked.

@tonjaggart, is 'store.php' clonable (i.e. has several pages)?
I am assuming store.php is clonable in this case, otherwise as you stated, it should have worked. Could cms:get_custom_field have been fetching the value from a different clonable page - perhaps the first in ascending publish date order?
Yes, that is what I guess must be happening - if store is clonable cms:get_custom_field would also expect a page to be specified e.g.
Code: Select all
<cms:get_custom_field 'testimonial_enable' masterpage='store.php' page='some_page' />

Without the 'page' parameter e.g. as follows
Code: Select all
<cms:get_custom_field 'testimonial_enable' masterpage='store.php'/>
-the tag will fetch data from the 'default' page (i.e. the first page cloned page that was created).
10 posts Page 1 of 1
cron