Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
I need to have a dropdown function in admin panel, to indicate if they got related products or not. something like this:

<cms: if....>
<cms:repeatable name='related_products' label='Photos' desc="Related Products" >
<cms:editable type='image' name='related_images' label='Photo' show_preview='1' preview_width='150' input_width='100' col_width='150' enforce_max='0' height="600" />
<cms:editable type='text' label='Product Label' name='pro_label' input_width='100' col_width='150' />
</cms:repeatable>
<cms: else...>
an empty message, "no related products".
</cm:if>

If user choose "yes" from dropdown, the repeated region will be shown, if they choose "no", a message will display "no related products". How can this be achieved??
Hi,

Currently the only possible way would be to use an editable region of type 'message' to inject JS into the admin-panel.

You can then use the JS to bind onChange event of the dropdown to set the visibility of the repeatable regions (you can find the unique IDs of all blocks using Chrome inspector or other tools).

Hope it helps.
@KK,

I tried to do it this way:

inside <template></template>:

<cms:editable
name="related_selection"
label="Got Related Products?"
desc="Select one from these"
opt_values='No | Yes'
type='dropdown'
/>


In the front, product page, product.php, I only want it to show and hide some part:
<cms:if opt_values = 'Yes' >
<cms:show_repeatable 'related_products' >
<a class="fancybox-thumbs fancybox-button" rel="<cms:show k_page_id />" href="<cms:show related_images />" title="<cms:show pro_label />"></a>
</cms:show_repeatable>
<cms:else />
no related products
</cms:if>

Can this work?
Apologies but I think I misunderstood your original question.
Do you wish to have those repeatable regions shown/hidden on the frontend or the back-end admin panel?

The solution I proposed was for the back-end.

Doing that on the front-end, would be a lot simpler. Your solution should work just fine.
@KK,

Actually I am now using fancybox to group related products:
<a class="fancybox-thumbs fancybox-button" rel="<cms:show k_page_id />" href="<cms:show related_images />" title="<cms:show pro_label />"></a>

If the products has no related products, it will show a empty image in fancybox pop-up, thus I like to make a second statement, put rel="0", so that won't link to any product and remain hidden...

I like to setup some sort of dropdown selection on backend, admin can choose whether they want to display related photos or not, for backend:
<cms:editable
name="related_selection"
label="Got Related Products?"
desc="Select one from these"
opt_values='No | Yes'
type='dropdown'
/>

And If the system detect "Yes", the front end will display:
Code: Select all
<cms:if opt_values = 'Yes' >
<cms:show_repeatable 'related_products' >
<a class="fancybox-thumbs fancybox-button" rel="<cms:show k_page_id />" href="<cms:show related_images />" title="<cms:show pro_label />"></a>
</cms:show_repeatable>
<cms:else />
<cms:show_repeatable 'related_products' >
<a class="fancybox-thumbs fancybox-button" rel="0" href="<cms:show related_images />" title="<cms:show pro_label />"></a>
</cms:show_repeatable>
</cms:if>
@KK,

I'm sorry for always asking stupid question, It did worked, I put the wrong name:
<cms:if opt_values = 'Yes' >
<cms:show_repeatable 'related_products' >
<a class="fancybox-thumbs fancybox-button" rel="<cms:show k_page_id />" href="<cms:show related_images />" title="<cms:show pro_label />"></a>
</cms:show_repeatable>
<cms:else />
<cms:show_repeatable 'related_products' >
<a class="fancybox-thumbs fancybox-button" rel="0" href="<cms:show related_images />" title="<cms:show pro_label />"></a>
</cms:show_repeatable>
</cms:if>

not opt_values = 'Yes', is related_selection = 'Yes'...

You must be driven crazy by the client like me....
6 posts Page 1 of 1