-
March 14, 2019, 08:05 PM
#1
Senior Member
Smarty "If" statement for data item
I have a field named Seller Type (key:seller_type) with 3 dropdown values. I want to use an if statement for seller_type == cdcretail (cdcretail is the data item in the Seller Type data entry).
I initially tried the code below but it had no affect:
{if $seller_type == "cdcretaill"}
<style>
{literal}
.standard-form, .dealer-form, .dc-wholesale-form{
display: none;}
{/literal}
</style>
{/if}
I'm very new to smarty and I looked at their forum but haven't had any success. Can anyone help with this?
Thanks,
Jason
EDIT:
Ok, I have this part sorted.
I'm starting to like Smarty.
I ended up creating a separate form for each seller type and adding this to listing_details_seller.tpl:
{if $seller_type_value = seller_type_cdcretail}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'contact _seller_form_cdcretail.tpl'}
{elseif $seller_type_value = seller_type_cdcwholesale}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'contact _seller_form_cdcwholesale.tpl'}
{elseif $seller_type_value = seller_type_standard_dealer}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'contact _seller_form_dealer.tpl'}
{else $seller_type_value = seller_type_private_seller}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'contact _seller_form.tpl'}
{/if}
Last edited by Jason Barbour; March 14, 2019 at 08:36 PM.
Reason: Solved
-
March 14, 2019, 09:31 PM
#2
Senior Member
My previous solution was incorrect.
Here is the correct one if anyone needs it:
{if $listing_data.seller_type_field eq 'seller_type_private_seller'}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'contact _seller_form.tpl'}
{elseif $listing_data.seller_type_field eq 'seller_type_cdcretail'}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'contact _seller_form_cdcretail.tpl'}
{elseif $listing_data.seller_type_field eq 'seller_type_cdcwholesale'}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'contact _seller_form_cdcwholesale.tpl'}
{else $listing_data.seller_type_field eq 'seller_type_standard_dealer'}
{include file='blocks'|cat:$smarty.const.RL_DS|cat:'contact _seller_form_dealer.tpl'}
{/if}
Last edited by Jason Barbour; March 14, 2019 at 09:58 PM.