Jump to content

feature without value


koubin

Recommended Posts

I need to set a Feature without value. The reason for that is that I use the features to display flags in product-flags.tpl (like this)

{foreach from=$product.features item=vlastnost}
	<li class="product-flag fl-{$vlastnost.id_feature}">{$vlastnost.name}</li>
{/foreach}

and the feature name is enough for me. At the same time I need the process to be simple for a person who will add product and features (in another words, avoid two SELECT menus).

When I use the feature without value in product and save it, it is not there after refresh and also it is not available in the $product.features array.

Do I have any options here?

Thanks

Link to comment
Share on other sites

On 9/17/2021 at 9:45 PM, koubin said:

I need to set a Feature without value. The reason for that is that I use the features to display flags in product-flags.tpl (like this)

{foreach from=$product.features item=vlastnost}
	<li class="product-flag fl-{$vlastnost.id_feature}">{$vlastnost.name}</li>
{/foreach}

and the feature name is enough for me. At the same time I need the process to be simple for a person who will add product and features (in another words, avoid two SELECT menus).

When I use the feature without value in product and save it, it is not there after refresh and also it is not available in the $product.features array.

Do I have any options here?

Thanks

I'm not sure if I understood your issue/request correctly, but from my point of view it shouldn't be too complicated.

 

As for setting the feature, you can add it through the admin panel as you'd add any other one, selecting the feature and asigning a value. In your template, you can re-use your current flags foreach, adding an if-else clause:

{if $vlastnost.id_feature == 'id you want only the name for'}

{$vlastnost.name}

{else}

{$vlastnost.name} {$vlastnost.value}

{/if}

Or even better, you can filter by value, inserting a simmilar if else clause inside your foreach:


{if $vlastnost.id_feature == 'your_id' AND $vlastnost.value == 'your_desired value'}

{$vlastnost.name}

{/if}

That way, even if you mistakenly assign a value to that specific feature, it won't show unless the value is something you've previously defined, like "True", or "Yes", "No"... etc..

Link to comment
Share on other sites

  • 3 weeks later...
On 9/24/2021 at 3:25 PM, Luis C said:

I'm not sure if I understood your issue/request correctly, but from my point of view it shouldn't be too complicated.

 

As for setting the feature, you can add it through the admin panel as you'd add any other one, selecting the feature and asigning a value. In your template, you can re-use your current flags foreach, adding an if-else clause:

{if $vlastnost.id_feature == 'id you want only the name for'}

{$vlastnost.name}

{else}

{$vlastnost.name} {$vlastnost.value}

{/if}

Or even better, you can filter by value, inserting a simmilar if else clause inside your foreach:


{if $vlastnost.id_feature == 'your_id' AND $vlastnost.value == 'your_desired value'}

{$vlastnost.name}

{/if}

That way, even if you mistakenly assign a value to that specific feature, it won't show unless the value is something you've previously defined, like "True", or "Yes", "No"... etc..

Thank you, but what I am trying to set up is the backoffice. As of my understanding, the features need to have name and value set in order to be saved and used. 

What I want, is to have just a feature (set by name) and therfore in backoffice when selecting a feature I don't have to select feature name in one SELECT box and then select feature value in the second SELECT box. Basically I want to set just feature to be on product (true) or not to be on product (false).

This I want to use for a custom flags like "new", "on sale"... Just to mention, the built in feature for "NEW" when the product is new for X days and "SALE" for discounted product are not usable for me as I want to be able to set those flags independently

Thanks

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...