Herland Posted June 13, 2013 Share Posted June 13, 2013 (edited) Don't confusse yourself by the code, it's simple and clean. I used product reference to sort the accessories. The point is that, it works in the first reference, very well. But it's not doing so in the second list. Right now I will post two code blocks and you will see that I divide them by reference: First code block, corresponding to the first reference: <ul style="float:left;width:700px;"> {foreach from=$accessories item=accessory name=accessories_list} {assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)} {$referencia = explode(' ',trim($accessory.reference))} <!--customized line--> {if $referencia[0]=="Brazo"} <a style="visibility:hidden">{$a++}</a> {if $a==1}<li class="referencia_li"><span class="referencia">Brazos</span></li><br><br>{/if} <!--customized line--> <li class="ajax_block_product item product_accessories_description accesorios_li"> <h5><a href="{$accessoryLink|escape:'htmlall':'UTF-8'}">{$accessory.name|truncate:22:'...':true|escape:'htmlall':'UTF-8'}</a></h5> <div class="product_desc"> <a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{$accessory.legend|escape:'htmlall':'UTF-8'}" class="product_image"><img src="{$link->getImageLink($accessory.link_rewrite, $accessory.id_image, 'medium')}" alt="{$accessory.legend|escape:'htmlall':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" /></a> <a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{l s='More'}" class="product_description">{$accessory.description_short|strip_tags|truncate:70:'...'}</a> </div> <p class="product_accessories_price"> <input type="checkbox" name="chkAcc" class="brazo likeRadio" value="{$accessory.id_product|intval}" icost="{$accessory.price}" /> {if $accessory.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<span class="price">{if $priceDisplay != 1}{displayWtPrice p=$accessory.price}{else}{displayWtPrice p=$accessory.price_tax_exc}{/if}</span>{/if} <!-- <a class="button" href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{l s='View'}">{l s='View'}</a>--> {if ($accessory.allow_oosp || $accessory.quantity > 0) AND $accessory.available_for_order AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE} <!--<a class="exclusive button ajax_add_to_cart_button" href="{$link->getPageLink('cart.php')}?qty=1&id_product={$accessory.id_product|intval}&token={$static_token}&add" rel="ajax_id_product_{$accessory.id_product|intval}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>--> {else} <!--<span class="exclusive">{l s='Add to cart'}</span> <span class="availability">{if (isset($accessory.quantity_all_versions) && $accessory.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>--> {/if} </p> </li> {/if}<!--Fin if de referencia --> {/foreach} </ul> Second code block, corresponding to the second reference: <ul style="float:left;width:700px;"> {foreach from=$accessories item=accessory name=accessories_list} {assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)} {$referencia = explode(' ',trim($accessory.reference))} {if $referencia[0]=="Mecanismo"} <a style="visibility:hidden">{$y++}</a> {if $y==1}<li class="referencia_li"><span class="referencia">Mecanismo</span></li><br><br>{/if} <li class="ajax_block_product item product_accessories_description accesorios_li"> <h5><a href="{$accessoryLink|escape:'htmlall':'UTF-8'}">{$accessory.name|truncate:22:'...':true|escape:'htmlall':'UTF-8'}</a></h5> <div class="product_desc"> <a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{$accessory.legend|escape:'htmlall':'UTF-8'}" class="product_image"><img src="{$link->getImageLink($accessory.link_rewrite, $accessory.id_image, 'medium')}" alt="{$accessory.legend|escape:'htmlall':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" /></a> <a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{l s='More'}" class="product_description">{$accessory.description_short|strip_tags|truncate:70:'...'}</a> </div> <p class="product_accessories_price"> <input type="checkbox" name="chkAcc" class="brazo likeRadio" value="{$accessory.id_product|intval}" icost="{$accessory.price}" /> {if $accessory.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<span class="price">{if $priceDisplay != 1}{displayWtPrice p=$accessory.price}{else}{displayWtPrice p=$accessory.price_tax_exc}{/if}</span>{/if} <!-- <a class="button" href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{l s='View'}">{l s='View'}</a>--> {if ($accessory.allow_oosp || $accessory.quantity > 0) AND $accessory.available_for_order AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE} <!--<a class="exclusive button ajax_add_to_cart_button" href="{$link->getPageLink('cart.php')}?qty=1&id_product={$accessory.id_product|intval}&token={$static_token}&add" rel="ajax_id_product_{$accessory.id_product|intval}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>--> {else} <!--<span class="exclusive">{l s='Add to cart'}</span> <span class="availability">{if (isset($accessory.quantity_all_versions) && $accessory.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>--> {/if} </p> </li> {/if}<!--Fin if de referencia --> {/foreach} </ul> In the tests that I made, I could notice that if I didn't add the customized code (the reference thing) every <ul> block would work well, but when I added the customized code, it just doesn't. I just don't understand why! I even changed the name of the variable receiving all the explode thing, but still. Sorry if I explained myself in a bit confussing manner, but if you want to feed, I can answer any question. Edited June 13, 2013 by Herland (see edit history) Link to comment Share on other sites More sharing options...
Herland Posted June 13, 2013 Author Share Posted June 13, 2013 (edited) Thanks to the hundreds of replies lol. The code works perfectly, I just was testing a product that didn't have that kind of accessory (my bad) now my client is happy. So this is a kind of developement gift. Good luck on implementing it. Edited June 13, 2013 by Herland (see edit history) 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