Jump to content

Déplacer les attributs couleur de la page produit dans une autre colonne ?


Zun

Recommended Posts

Bonjour,

 

J'aimerai savoir s'il est possible d'afficher les attributs couleur de la page produit (product.tpl) dans une autre colonne ?

 

Autrement dit, est-il possible de séparer ce code en 2 pour bouger la partie "color" sur une autre colonne ?

 {if isset($groups)}
							<!-- attributes -->
							<div id="attributes">
								<div class="clearfix"></div>
								{foreach from=$groups key=id_attribute_group item=group}
									{if $group.attributes|@count}
										<fieldset class="attribute_fieldset">
											<label class="attribute_label" {if $group.group_type != 'color' && $group.group_type != 'radio'}for="group_{$id_attribute_group|intval}"{/if}>{$group.name|escape:'html':'UTF-8'} </label>
											{assign var="groupName" value="group_$id_attribute_group"}
											<div class="attribute_list">
												{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}
															{assign var='img_color_exists' value=file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}
															<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}"{if !$img_color_exists && isset($colors.$id_attribute.value) && $colors.$id_attribute.value} style="background:{$colors.$id_attribute.value|escape:'html':'UTF-8'};"{/if} title="{$colors.$id_attribute.name|escape:'html':'UTF-8'}">
																	{if $img_color_exists}
																		<img src="{$img_col_dir}{$id_attribute|intval}.jpg" alt="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" title="{$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}   
											</div> <!-- end attribute_list -->
										</fieldset>
									{/if}
								{/foreach}
							</div> <!-- end attributes -->

Merci :-D

 

 

Link to comment
Share on other sites

Bonjour:

Voilà une proposition à tester:

Groupe 1:

{if isset($groups)}
	<!-- attributes -->
	<div id="attributes">
		<div class="clearfix"></div>
		{foreach from=$groups key=id_attribute_group item=group}
			{if $group.attributes|@count}
				<fieldset class="attribute_fieldset">
					<label class="attribute_label" {if $group.group_type != 'color' && $group.group_type != 'radio'}for="group_{$id_attribute_group|intval}"{/if}>{$group.name|escape:'html':'UTF-8'} </label>
					{assign var="groupName" value="group_$id_attribute_group"}
					<div class="attribute_list">
						{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')}

						{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}   
					</div> <!-- end attribute_list -->
				</fieldset>
			{/if}
		{/foreach}
	</div> 
	<!-- end attributes -->
{/if}

Groupe 2 (color)

 {if isset($groups)}
	<!-- attributes 2 (COLOR)-->
	<div id="attributes2">
		<div class="clearfix"></div>
		{foreach from=$groups key=id_attribute_group item=group}
			{if $group.attributes|@count}
				<fieldset class="attribute_fieldset">
					<label class="attribute_label" {if $group.group_type != 'color' && $group.group_type != 'radio'}for="group_{$id_attribute_group|intval}"{/if}>{$group.name|escape:'html':'UTF-8'} </label>
					{assign var="groupName" value="group_$id_attribute_group"}
					<div class="attribute_list">
						{if ($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}
									{assign var='img_color_exists' value=file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}
									<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}"{if !$img_color_exists && isset($colors.$id_attribute.value) && $colors.$id_attribute.value} style="background:{$colors.$id_attribute.value|escape:'html':'UTF-8'};"{/if} title="{$colors.$id_attribute.name|escape:'html':'UTF-8'}">
											{if $img_color_exists}
												<img src="{$img_col_dir}{$id_attribute|intval}.jpg" alt="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" title="{$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}   
					</div> <!-- end color_attribute_list -->
				</fieldset>
			{/if}
		{/foreach}
	</div> 
	<!-- end attributes2 (COLOR) -->
{/if}

Mais attention aux deux ID " attributes " et "attributes2dans les fichiers CSS

Link to comment
Share on other sites

Merci pour cette réponse S-Hammani, mais ça me fait une page blanche avec un message d'erreur :


Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "***/prestatest/themes/default-bootstrap/product.tpl" on line 540 "{/if}" unexpected closing tag <-- thrown in ***/prestatest/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 540

A la ligne 540, il y a seulement "{/if}"; c'est la fin du code de la colonne où j'ai remplacé "attributes" par ton code N°1.

 

-------------

 

En fait, on y est presque !

Si j'enlève "{/if}" de la fin de ton code "attributes2", la page reviens, les noms de chaque attribut (couleur et non couleur) est présent sur chaque colonnes.

Link to comment
Share on other sites

J'ai recopié précisément tes 2 codes qui sont bien structurés de cette manière:

{if isset($groups)}
       .... ici code du premier groupe ....
{/if}

{if isset($groups)}
       .... ici code du 2nd groupe ....
{/if}

Ça crée une page blanche qui disparait si j'enlève le premier "{/if}"

 

Je peux t'envoyer un lien vers une page produit ou le contenu de mon product.tpl en MP si tu veux y jeter un coup d’œil.

Link to comment
Share on other sites

Mince, les déclinaisons ne sont pas prises en compte, le prix ne change pas, les photos de produits ne changent pas non plus lorsque je clique sur une couleur: "Ce produit n'existe pas dans cette déclinaison. Vous pouvez néanmoins en sélectionner une autre."

Link to comment
Share on other sites

Bonjour à tous, 

J'ai un problème équivalent, sauf que je voudrais bouger toute la section attribute dans la right column et que tout se met à buger! J'y avais touché je crois mais il y a quelques années et avec de l'aide, alors je ne me souviens plus trop... Quand je mets le thème de base tout fonctionne, ça vient donc bien du mien

J'ai en plus un problème de warning: "this combination does not exist ..."

Voici le lien vers mon test:

http://dev.ireneirene.com/shop/home/1541-table-celeste.html

 

Et mon bout de code:

 

{if $product->description_short OR $packItems|@count > 0}

<div id="short_description_block" class="hidden">

{if $product->description_short}

<div id="short_description_content" class="rte align_justify">{$product->description_short}</div>

{/if}

{if $product->description}

<p class="buttons_bottom_block"><a href="javascript:{ldelim}{rdelim}" class="button">{l s='More details'}</a></p>

{/if}

{if $packItems|@count > 0}

<div class="short_description_pack">

<h3>{l s='Pack content'}</h3>

{foreach from=$packItems item=packItem}

<div class="pack_content">

{$packItem.pack_quantity} x <a href="{$link->getProductLink($packItem.id_product, $packItem.link_rewrite, $packItem.category)}">{$packItem.name|escape:'htmlall':'UTF-8'}</a>

<p>{$packItem.description_short}</p>

</div>

{/foreach}

</div>

{/if}

</div>

{/if}

 

{*{if isset($colors) && $colors}

<!-- colors -->

<div id="color_picker">

<p>{l s='Pick a color:' js=1}</p>

<div class="clear"></div>

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

{foreach from=$colors key='id_attribute' item='color'}

<li><a id="color_{$id_attribute|intval}" class="color_pick" style="background: {$color.value};" onclick="updateColorSelect({$id_attribute|intval});$('#wrapResetImages').show('slow');" title="{$color.name}">{if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}<img src="{$img_col_dir}{$id_attribute}.jpg" alt="{$color.name}" width="20" height="20" />{/if}</a></li>

{/foreach}

</ul>

<div class="clear"></div>

</div>

{/if}*}

 

{if ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}

<!-- add to cart form-->

<form id="buy_block" {if $PS_CATALOG_MODE AND !isset($groups) AND $product->quantity > 0}class="hidden"{/if} action="{$link->getPageLink('cart')}" method="post">

 

<!-- hidden datas -->

<p class="hidden">

<input type="hidden" name="token" value="{$static_token}" />

<input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" />

<input type="hidden" name="add" value="1" />

<input type="hidden" name="id_product_attribute" id="idCombination" value="" />

</p>

 

<div class="product_attributes">

{if isset($groups)}

<!-- attributes -->

<div id="attributes">

<div class="clear"></div>

{foreach from=$groups key=id_attribute_group item=group}

{if $group.attributes|@count}

<fieldset class="attribute_fieldset">

<label class="attribute_label" for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} : </label>

{assign var="groupName" value="group_$id_attribute_group"}

<div class="attribute_list">

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

<select name="{$groupName}" id="group_{$id_attribute_group|intval}" class="attribute_select" onchange="findCombination();getProductAttribute();">

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

<a id="color_{$id_attribute|intval}" class="color_pick{if ($group.default == $id_attribute)} selected{/if}" style="background: {$colors.$id_attribute.value};" title="{$colors.$id_attribute.name}" onclick="colorPickerClick(this);getProductAttribute();">

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

<img src="{$img_col_dir}{$id_attribute}.jpg" alt="{$colors.$id_attribute.name}" width="20" height="20" /><br />

{/if}

</a>

</li>

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

{$default_colorpicker = $id_attribute}

{/if}

{/foreach}

</ul>

<input type="hidden" class="color_pick_hidden" name="{$groupName}" value="{$default_colorpicker}" />

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

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

<input type="radio" class="attribute_radio" name="{$groupName}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} onclick="findCombination();getProductAttribute();">

{$group_attribute|escape:'htmlall':'UTF-8'}<br/>

{/foreach}

{/if}

</div>

</fieldset>

{/if}

{/foreach}

</div>

{/if}

 

<!-- availability -->

<p id="availability_statut" {if ($product->quantity <= 1 && !$product->available_later && $allow_oosp) OR ($product->quantity <=1 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>

<span id="availability_label">{l s='Availability:'}</span>

<span id="availability_value"{if $product->quantity <= 0} class="warning_inline"{/if}>

{if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->quantity}{/if}

</span>

</p>

 

<!-- quantity wanted -->

<p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 1) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>

<label>{l s='Quantity:'}</label>

<input type="text" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}" size="2" maxlength="3" {if $product->minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} />

</p>

 

<!-- minimal quantity wanted -->

<p id="minimal_quantity_wanted_p" class="hidden"{if $product->minimal_quantity <= 1 OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>

{l s='This product is not sold individually. You must select at least'} <b id="minimal_quantity_label">{$product->minimal_quantity}</b> {l s='quantity for this product.'}

</p>

{if $product->minimal_quantity > 1}

<script type="text/javascript">

checkMinimalQuantity();

</script>

{/if}

 

<!-- number of item in stock -->

{if ($display_qties == 1 && !$PS_CATALOG_MODE && $product->available_for_order)}

<p id="pQuantityAvailable"{if $product->quantity <= 0} style="display: none;"{/if}>

<span id="quantityAvailable">{$product->quantity|intval}</span>

<span {if $product->quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='Item in stock'}</span>

<span {if $product->quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='Items in stock'}</span>

</p>

{/if}

 

<!-- Out of stock hook -->

<div id="oosHook"{if $product->quantity > 0} style="display: none;"{/if}>

{$HOOK_PRODUCT_OOS}

</div>

 

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if} >{l s='Warning: Last items in stock!'}</p>

</div>

Link to comment
Share on other sites

Bonjour IreneIren, sur le thème de base, je sais comment faire, mais là, je ne peux pas t'aider...

 

 

Par contre, si quelqu'un à une idée pour modifier le code de S-Hammani pour qu'il n'afffiche plus ce message d'erreur: ""this combination does not exist ..."", ... ça me dépannerai beaucoup. ;):D

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