Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tips] Replace combo for single attribute
02-16-2010, 10:17 PM
Post: #1
[Tips] Replace combo for single attribute
Hello,

I finally figured out how not to appear as a text instead of a combo when an attribute group has only one attribute, to allow this to give critical information about a product without the characteristics

So in product.tpl you should replace:
PHP Code:
<!-- attributes -->
            <
div id="attributes">
            {foreach 
from=$groups key=id_attribute_group item=group}
            <
p>
                <
label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :</label>
                {
assign var='groupName' value='group_'|cat:$id_attribute_group}
                <
select name="{$groupName}" id="group_{$id_attribute_group|intval}">
                    {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_attributeselected="selected"{/if}>{$group_attribute|escape:'htmlall':'UTF-8'}</option>
                    {/foreach}
                </
select>
            </
p>
            {/foreach} 
To:
PHP Code:
<!-- attributes -->
            <
div id="attributes">
            {foreach 
from=$groups key=id_attribute_group item=group}
            <
p>
                <
label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :</label>
                {
assign var='groupName' value='group_'|cat:$id_attribute_group}
                {if 
count($group.attributes) > 1}
                <
select name="{$groupName}" id="group_{$id_attribute_group|intval}">
                    {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_attributeselected="selected"{/if}>{$group_attribute|escape:'htmlall':'UTF-8'}</option>
                    {/foreach}
                </
select>
                {else}
                    {foreach 
from=$group.attributes key=id_attribute item=group_attribute}
                        <
span class="editable">{$group_attribute|escape:'htmlall':'UTF-8'}</span>
                    {/foreach}
                {/if}
            </
p>
            {/foreach} 

Original source (in French) - here
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: