futureyoon Posted July 12, 2012 Share Posted July 12, 2012 Hi I would like to make some changes of the way to display product attributes. Current product.tpl is to use dropdown (select command) to show all individual attribute even for the single attribute. To be Continue to use the same way to display the product attributes. BUT I would like to put the condition as in if there is only a single attribute available, just display the value without the drop down menu as attached snapshot. I understand that changes need to be made somewhere below.. but I couldn't figure it out how/what to change for many days.... Please help? product.tpl line# 302 ----------------------------------------------------------------------------- {if isset($groups)} <!-- attributes --> <div id="attributes"> {foreach from=$groups key=id_attribute_group item=group} {if $group.attributes|@count} <p> <label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :</label> {assign var="groupName" value="group_$id_attribute_group"} <select name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};"> {foreach from=$group.attributes key=id_attribute item=group_attribute} <option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option> {/foreach} </select> </p> {/if} {/foreach} </div> {/if} ----------------------------------------------------------------------------- Link to comment Share on other sites More sharing options...
tomerg3 Posted July 12, 2012 Share Posted July 12, 2012 I think the easiest way would be to add a condition around this block, that checks if there is only 1 group with 1 attribute. If that is the case, add a display:none to it, and add your own attribute text display (without the select box). By hiding the attributes, you will ensure that you do not break any JS code. Link to comment Share on other sites More sharing options...
futureyoon Posted July 13, 2012 Author Share Posted July 13, 2012 Thx tomerg3. Yes, I understand it has to be somewhere there in that block.. i tried to modify here and there, but really no luck.. i know this might be too much, but do you know how/where/what to change to make it work that way? can you pinpoint? Link to comment Share on other sites More sharing options...
tomerg3 Posted July 13, 2012 Share Posted July 13, 2012 It sounds like you want me to write it for you, rather than ask a specific question. Link to comment Share on other sites More sharing options...
futureyoon Posted July 13, 2012 Author Share Posted July 13, 2012 i guess i was too frustrated with it. sorry if it sounded blunt to you. Thank you. Anyway i figured it out somehow after many tries.. here i insert the code for anyone looking for the similar solution. --------------------------------------------------------------------- {if isset($groups)} <!-- attributes --> <div id="attributes"> {foreach from=$groups key=id_attribute_group item=group} {if $group.attributes|@count} <p> {if $group.attributes|@count > 1} <label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :</label> {assign var="groupName" value="group_$id_attribute_group"} <select name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};"> {foreach from=$group.attributes key=id_attribute item=group_attribute} <option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option> {/foreach} </select> {elseif $group.attributes|@count <= 1} <label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :</label> {assign var="groupName" value="group_$id_attribute_group"} <select disabled="disabled" name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};"> <option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option> </select> {/if} </p> {/if} {/foreach} </div> {/if} ------------------------------------------------------------------------------------------- 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