Jump to content

Page produit : afficher couleurs + liste déroulante


Recommended Posts

Bonjour,

 

De mémoire il faut aller modifier l'affichage dans l'attribut concerné, en choisissant liste déroulante.

 

Si je mets liste déroulante, les couleurs ne s'affichent plus et je souhaite l'affichage des deux (liste déroulante + affichage des couleurs). J'ai modifié le code de product.tpl, j'arrive à afficher les deux, mais lorsque je sélectionne une couleurs sur les carrés de couleur, cela ne se répercute pas sur la liste déroulante.

 

J'ai modifié ça :

 

{if ($group.group_type == 'select')}

                                                    <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="form-control attribute_select no-print">

                                                        {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:'html':'UTF-8'}">{$group_attribute|escape:'html':'UTF-8'}</option>

                                                        {/foreach}

                                                    </select>

                                                {elseif ($group.group_type == 'color')}

                                                    <ul id="color_to_pick_list" class="clearfix">

                                                        {assign var="default_colorpicker" value=""}

                                                        {foreach from=$group.attributes key=id_attribute item=group_attribute}

                                                            <li{if $group.default == $id_attribute} class="selected"{/if}>

                                                                <a href="{$link->getProductLink($product)|escape:'html':'UTF-8'}" id="color_{$id_attribute|intval}" name="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" class="color_pick{if ($group.default == $id_attribute)} selected{/if}" style="background: {$colors.$id_attribute.value|escape:'html':'UTF-8'};" title="{$colors.$id_attribute.name|escape:'html':'UTF-8'}">

                                                                    {if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}

                                                                        <img src="{$img_col_dir}{$id_attribute|intval}.jpg" alt="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" width="20" height="20" />

                                                                    {/if}

                                                                </a>

                                                            </li>

                                                            

                                                            {if ($group.default == $id_attribute)}

                                                                {$default_colorpicker = $id_attribute}

                                                            {/if}

                                                        {/foreach}

                                                    </ul>

                                                    <input type="hidden" class="color_pick_hidden" name="{$groupName|escape:'html':'UTF-8'}" value="{$default_colorpicker|intval}" />

                                                {elseif ($group.group_type == 'radio')}

                                                    <ul>

                                                        {foreach from=$group.attributes key=id_attribute item=group_attribute}

                                                            <li>

                                                                <input type="radio" class="attribute_radio" name="{$groupName|escape:'html':'UTF-8'}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} />

                                                                <span>{$group_attribute|escape:'html':'UTF-8'}</span>

                                                            </li>

                                                        {/foreach}

                                                    </ul>

                                                {/if}

 

En ça :

{if ($group.group_type == 'select' || $group.group_type == 'color')}

                                                    <select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="form-control attribute_select no-print">

                                                        {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:'html':'UTF-8'}">{$group_attribute|escape:'html':'UTF-8'}</option>

                                                        {/foreach}

                                                    </select>

                                                {if ($group.group_type == 'color')}

                                                <br/>

                                                    <ul id="color_to_pick_list" class="clearfix">

                                                        {assign var="default_colorpicker" value=""}

                                                        {foreach from=$group.attributes key=id_attribute item=group_attribute}

                                                            <li{if $group.default == $id_attribute} class="selected"{/if}>

                                                                <a href="{$link->getProductLink($product)|escape:'html':'UTF-8'}" id="color_{$id_attribute|intval}" name="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" class="color_pick{if ($group.default == $id_attribute)} selected{/if}" style="background: {$colors.$id_attribute.value|escape:'html':'UTF-8'};" title="{$colors.$id_attribute.name|escape:'html':'UTF-8'}">

                                                                    {if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}

                                                                        <img src="{$img_col_dir}{$id_attribute|intval}.jpg" alt="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" width="20" height="20" />

                                                                    {/if}

                                                                </a>

                                                            </li>

                                                            

                                                            {if ($group.default == $id_attribute)}

                                                                {$default_colorpicker = $id_attribute}

                                                            {/if}

                                                        {/foreach}

                                                    </ul>

                                                    <input type="hidden" class="color_pick_hidden" name="{$groupName|escape:'html':'UTF-8'}" value="{$default_colorpicker|intval}" />

                                                {/if}

                                                {elseif ($group.group_type == 'radio')}

                                                    <ul>

                                                        {foreach from=$group.attributes key=id_attribute item=group_attribute}

                                                            <li>

                                                                <input type="radio" class="attribute_radio" name="{$groupName|escape:'html':'UTF-8'}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} />

                                                                <span>{$group_attribute|escape:'html':'UTF-8'}</span>

                                                            </li>

                                                        {/foreach}

                                                    </ul>

                                                {/if}

Link to comment
Share on other sites

  • 1 year later...

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