Jump to content

Text by feature value


Amparfum

Recommended Posts

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 by Amparfum (see edit history)
Link to comment
Share on other sites

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

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

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

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

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 by shokinro (see edit history)
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...