Jump to content

Attributes - disable select tag when attribute has just one value


syrovidis

Recommended Posts

Hello,

another question. How to disable SELECT tag in attributes, when attribute has just one value?

I use attributes also for attributes filter search and I need to set them even if they have just one value. Disabling of SELECT tags of these attributes would be a good solution for me.

Thank you for help.

Link to comment
Share on other sites

It's the following on lines 236-253 of product.tpl (in PrestaShop v1.3.2) that you will need to change:

{if isset($groups)}
<!-- attributes -->

{foreach from=$groups key=id_attribute_group item=group}
{if $group.attributes|@count}


{$group.name|escape:'htmlall':'UTF-8'} :
   {assign var='groupName' value='group_'|cat:$id_attribute_group}
0}$('#resetImages').show('slow');{/if}">
       {foreach from=$group.attributes key=id_attribute item=group_attribute}
{$group_attribute|escape:'htmlall':'UTF-8'}
       {/foreach}


{/if}
{/foreach}

{/if}



To hide attribute groups with only one item, you could change line 241 to:





or to disable the dropdown, add the following before the > at the end of the select on line 244:

{if $group.attributes|@count == 1} disabled="disabled"{/if}

Link to comment
Share on other sites

  • 5 months later...

That is a good idea, but I don't know exaclty how to implement it on 1.4

in my product.tpl I've got:

            {if $group.attributes|@count}


{$group.name|escape:'htmlall':'UTF-8'} :
               {assign var="groupName" value="group_$id_attribute_group"}
0}$('#wrapResetImages').show('slow');{/if};">
                   {foreach from=$group.attributes key=id_attribute item=group_attribute}
{$group_attribute|escape:'htmlall':'UTF-8'}
                   {/foreach}


           {/if}
           {/foreach}



But after replacing

{if $group.attributes|@count}


with any of the options above i get a blank product page.

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