Amparfum Posted April 26, 2016 Share Posted April 26, 2016 (edited) Dear friends, I am trying to make this thing work in product.tpl - if my feature.name is 'Delivery' and value is '4-15 days' OR if value is empty, I need to display text 'Delivery 4-15 days'. In other cases, if value is '1-2 days' or so - no need to display the text. Here's what I have now: {if $feature.name == 'Delivery'} {if $feature.value == '4-15 days'} <h1><b><left><label>{l s='Delivery 4-15 days'}</label></b></left></h1> {/if} {/if} This works fine, but only if the '4-15 days' value is selected. I need it to work if that value is empty aswell. So far I've tried this: {if $feature.value == '4-15 days' OR !empty($feature->value)} {if $feature.name == 'Delivery' && !empty($feature->value)} Tried it in the same if, as well as in another if. Any help would be much appreciated. Edited April 27, 2016 by Amparfum (see edit history) Link to comment Share on other sites More sharing options...
shokinro Posted April 26, 2016 Share Posted April 26, 2016 have you tried this one {if $feature.name == 'Delivery'} {if $feature.value == '4-15 days' OR !empty($feature.value)} <h1><b><left><label>{l s='Delivery 4-15 days'}</label></b></left></h1> {/if} {/if} Here $feature is not an object, so you can not use $feature->value Link to comment Share on other sites More sharing options...
Amparfum Posted April 26, 2016 Author Share Posted April 26, 2016 shokinro, Thank you for you help. Yes, I have tried this. If I use this code you suggested, suddenly both '1-2 days' and '4-15 days' values react to it and display 'Delivery 4-15 days', whereas the empty value shows nothing. Link to comment Share on other sites More sharing options...
shokinro Posted April 26, 2016 Share Posted April 26, 2016 that is what you wanted? I do not know you have other values like 1-2 days. try this one then {if $feature.name == 'Delivery'} {if $feature.value == '4-15 days' OR empty($feature.value)} <h1><b><left><label>{l s='Delivery 4-15 days'}</label></b></left></h1> {/if}{/if} Link to comment Share on other sites More sharing options...
Amparfum Posted April 26, 2016 Author Share Posted April 26, 2016 Tried it, does not work Once again, I want if feature value is empty or if it is '4-15 days' to display the text. If the value is '1-2 days' or a different value - not display. Sorry if I did not describe it properly, my english isn't that good Link to comment Share on other sites More sharing options...
shokinro Posted April 26, 2016 Share Posted April 26, 2016 (edited) the code should be working. really do not know what you want to do now. since everything time you are saying different thing. What is your default value???? This is last try. {if $feature.name == 'Delivery'} {if $feature.value == '4-15 days' OR empty($feature.value)} <h1><b><left><label>{l s='Delivery 4-15 days'}</label></b></left></h1> {/if} {if $feature.value == '1-2 days'} {/if} {/if} Edited April 26, 2016 by shokinro (see edit history) Link to comment Share on other sites More sharing options...
Amparfum Posted April 27, 2016 Author Share Posted April 27, 2016 This did not work. However, I came up with my own solution, since the empty($feature.value) seemed to have no impact whatsoever. <div id="delivery"{if $feature.name == 'Delivery' && $feature.value == '1-2 days'} style="display: none;"{/if}> <h1><b><left><label>{l s='Delivery 4-15 days'}</label></b></left></h1> </div> This displays the 'Delivery 4-15 days' text all the same, except when the feature value is 1-2 days. You could add more feature values that you need to exclude, it would look like this: <div id="delivery"{if $feature.name == 'Delivery' && $feature.value == '1-2 days' OR $feature.value == '3-4 days' OR $feature.value == '5-6 days'} style="display: none;"{/if}> <h1><b><left><label>{l s='Delivery 4-15 days'}</label></b></left></h1> </div> Again, this excludes the mentioned values, which means if the value is 7-8 days, the text would be displayed, but if the value is 3-4 days, 5-6 days, 1-2 days, the text is not displayed. Hope that helps someone in the future. Thanks for you help, shokinro, have a good one. Someone mark this as solved pls. Link to comment Share on other sites More sharing options...
shokinro Posted April 27, 2016 Share Posted April 27, 2016 (edited) @Amparfum Not sure why the empty() did not work out, I am glad you finally figured out a solution. and thanks for update and sharing. Edited April 27, 2016 by shokinro (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now