tozi Posted December 29, 2013 Share Posted December 29, 2013 (edited) Hi all, how ca i fix this problem with lenght of title? My page http://presta.simplydesign.sk/index.php blockcart.tpl <a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|escape:'html'}" title="{$product.name|truncate:100:'...'|escape:html:'UTF-8'}"> {$product.name|truncate:15:'...'|escape:html:'UTF-8'}</a> blockcart-json.tpl {ldelim} "products": [ {if $products} {foreach from=$products item=product name='products'} {assign var='productId' value=$product.id_product} {assign var='productAttributeId' value=$product.id_product_attribute} {ldelim} "id": {$product.id_product}, "link": "{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|addslashes|replace:'\\\'':'\''}", "quantity": {$product.cart_quantity}, "priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "name": "{$product.name|html_entity_decode:2:'UTF-8'|truncate:15:'...':true|escape:'htmlall'}", "price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "price_float": "{$product.total}", "idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if}, "idAddressDelivery": {if isset($product.id_address_delivery)}{$product.id_address_delivery}{else}0{/if}, "is_gift" : {if isset($product.is_gift) && $product.is_gift}1{else}0{/if}, {if isset($product.attributes_small)} "hasAttributes": true, "attributes": "{$product.attributes_small|addslashes|replace:'\\\'':'\''}", {else} "hasAttributes": false, {/if} "hasCustomizedDatas": {if isset($customizedDatas.$productId.$productAttributeId)}true{else}false{/if}, "customizedDatas":[ {if isset($customizedDatas.$productId.$productAttributeId[$product.id_address_delivery])} {foreach from=$customizedDatas.$productId.$productAttributeId[$product.id_address_delivery] key='id_customization' item='customization' name='customizedDatas'}{ldelim} {* This empty line was made in purpose (product addition debug), please leave it here *} "customizationId": {$id_customization}, "quantity": "{$customization.quantity}", "datas": [ {foreach from=$customization.datas key='type' item='datas' name='customization'} {ldelim} "type": "{$type}", "datas": [ {foreach from=$datas key='index' item='data' name='datas'} {ldelim} "index": {$index}, "value": "{Tools::nl2br($data.value|addslashes|replace: '\\\'':'\'')}", "truncatedValue": "{Tools::nl2br($data.value|truncate:28:'...'|addslashes|replace: '\\\'':'\'')}" {rdelim}{if !$smarty.foreach.datas.last},{/if} {/foreach}] {rdelim}{if !$smarty.foreach.customization.last},{/if} {/foreach} ] {rdelim}{if !$smarty.foreach.customizedDatas.last},{/if} {/foreach} {/if} ] {rdelim}{if !$smarty.foreach.products.last},{/if} {/foreach}{/if} ], "discounts": [ {if $discounts}{foreach from=$discounts item=discount name='discounts'} {ldelim} "id": "{$discount.id_discount}", "name": "{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|addslashes|replace:'\\\'':'\''}", "description": "{$discount.description|addslashes|replace:'\\\'':'\''}", "nameDescription": "{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|addslashes|replace:'\\\'':'\''}", "code": "{$discount.code}", "link": "{$link->getPageLink("$order_process", true, NULL, "deleteDiscount={$discount.id_discount}")|escape:'html'}", "price": "{if $priceDisplay == 1}{convertPrice|html_entity_decode:2:'UTF-8' price=$discount.value_tax_exc}{else}{convertPrice|html_entity_decode:2:'UTF-8' price=$discount.value_real}{/if}", "price_float": "{if $priceDisplay == 1}{$discount.value_tax_exc}{else}{$discount.value_real}{/if}" {rdelim} {if !$smarty.foreach.discounts.last},{/if} {/foreach}{/if} ], "shippingCost": "{$shipping_cost|html_entity_decode:2:'UTF-8'}", "shippingCostFloat": "{$shipping_cost_float|html_entity_decode:2:'UTF-8'}", {if isset($tax_cost)} "taxCost": "{$tax_cost|html_entity_decode:2:'UTF-8'}", {/if} "wrappingCost": "{$wrapping_cost|html_entity_decode:2:'UTF-8'}", "nbTotalProducts": "{$nb_total_products}", "total": "{$total|html_entity_decode:2:'UTF-8'}", "productTotal": "{$product_total|html_entity_decode:2:'UTF-8'}", {if isset($errors) && $errors} "hasError" : true, "errors" : [ {foreach from=$errors key=k item=error name='errors'} "{$error|addslashes|html_entity_decode:2:'UTF-8'}" {if !$smarty.foreach.errors.last},{/if} {/foreach} ] {else} "hasError" : false {/if} {rdelim} ajax-cart.js if ($('#cart_block_product_'+ domIdProduct).length == 0) { var productId = parseInt(this.id); var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0); var content = '<dt class="hidden" id="cart_block_product_' + domIdProduct + '">'; content += '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span>x</span>'; var min = this.name.indexOf(';', 100); var name = (this.name.length > 100 ? this.name.substring(0, 100) + '...' : this.name); content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + this.name + '</a>'; Edited December 29, 2013 by tozi (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted December 29, 2013 Share Posted December 29, 2013 but the question is: what problem you've got? "ca i fix this problem with lenght of title?" it's not enough to understand the problem i checked your page and everything is fine there. Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 Top cart. If you insert the product into the cart. I need whole name of product in title. Now there is only the short name. Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 (edited) Hi. The name is truncated when it's passed to the javascript function. You need to override the 'modules/blockcart/blockcart-json.tpl' file and remove the truncate function on line 36. Also remove the truncate function from 'modules/blockcart/blockcart.tpl' Regards.Robin.The CartExpert Team Edited December 29, 2013 by CartExpert.net (see edit history) Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 Thanks but when i delete truncate. So I get the full name of the product. I need the short name of the product and the full name of the product in the title. Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 You can pass the whole name via 'blockcart-json.tpl' and truncate it with javascript. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 Milos, it did not help. Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 CartExpert and how? Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 (edited) Remove the truncate at the product name (not the discount name): "name": "{$product.name|html_entity_decode:2:'UTF-8'|truncate:15:'...':true|escape:'htmlall'}", Edit the javascript file: var name = (this.name.length > 100 ? this.name.substring(0, 100) + '...' : this.name); var name_short = this.name.substring(0, 15) + '...' : this.name; // YOU CAN CHANGE 15 TO OTHER VALUE content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' +name_short + '</a>'; Regards.Robin.The CartExpert Team Edited December 29, 2013 by CartExpert.net (see edit history) Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 (edited) I know i remove truncate like this "name": "{$product.name|html_entity_decode:2:'UTF-8'|escape:'htmlall'}", But look now at the cart. It's not what I need. This appears correctly after reloading a page. Edited December 29, 2013 by tozi (see edit history) Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 The blockcart.tpl is also truncating the name. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 (edited) Yes,I set there 11 characters. And? Showing it's still the same. <a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|escape:'html'}" title="{$product.name|escape:html:'UTF-8'}"> {$product.name|truncate:11:'...'|escape:html:'UTF-8'}</a> Edited December 29, 2013 by tozi (see edit history) Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 You didn't change the javascript file. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 (edited) In ajax-cart.js i set (I do not know if I got it right. But it does not work.) var min = this.name.indexOf(';', 10); var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name); content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + this.name + '</a>'; Edited December 29, 2013 by tozi (see edit history) Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 You store the truncated name in the 'name' variable, yet that is not the one you display. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 I do not know what you mean. Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 (edited) So again. How to set the length of the product title in the cart. No length of the product name in the cart. Trying to rewrite truncate several hours. But does not work for me. Only after reloading the page. Edited December 29, 2013 by tozi (see edit history) Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 You store the truncated name in the 'name' variable, but you don't use it: var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name); You are displaying 'this.name'. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 Still do not understand. So i must rewrite some in here? <a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|escape:'html'}" title="{$product.name|escape:html:'UTF-8'}"> {$product.name|truncate:16:'...'|escape:html:'UTF-8'}</a> or here? var name = (this.name.length > 30 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name); content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + this.name + '</a>'; I'm confused. Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + this.name + '</a>'; Your are displaying 'this.name', and not 'name'. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 content += '<a href="' + this.link + '" title="' + name + '" class="cart_block_product_name">' + this.name + '</a>'; still not working Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 this.name is the long version. name is the truncated version. You are putting 'name' (the truncated version) in the title. And your javascript file shows no changes, it has this line: content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + this.name + '</a>'; Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 Look yet http://presta.simplydesign.sk/. There are 3 dots. Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 Now I noticed that you wrote earlier. var name_short = this.name.substring(0, 15) + '...' : this.name; // YOU CAN CHANGE 15 TO OTHER VALUE He writes me a syntax error and it locks animation cart. Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 ':this.name' should not be there. Now you have: var name = this.name.substring(0, 30) + '...'; var name_short = this.name.substring(0, 30) + '...'; Both variables are truncated!!! Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 (edited) I dont know what you mean "Both variables are truncated!!!" Edited December 29, 2013 by tozi (see edit history) Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 I dont know when is the problem... blockcart-json.tpl {ldelim} "products": [ {if $products} {foreach from=$products item=product name='products'} {assign var='productId' value=$product.id_product} {assign var='productAttributeId' value=$product.id_product_attribute} {ldelim} "id": {$product.id_product}, "link": "{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|addslashes|replace:'\\\'':'\''}", "quantity": {$product.cart_quantity}, "priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "name": "{$product.name|html_entity_decode:2:'UTF-8'|truncate:16:'...':true|escape:'htmlall'}", "price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "price_float": "{$product.total}", "idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if}, "idAddressDelivery": {if isset($product.id_address_delivery)}{$product.id_address_delivery}{else}0{/if}, "is_gift" : {if isset($product.is_gift) && $product.is_gift}1{else}0{/if}, {if isset($product.attributes_small)} "hasAttributes": true, "attributes": "{$product.attributes_small|addslashes|replace:'\\\'':'\''}", {else} "hasAttributes": false, {/if} "hasCustomizedDatas": {if isset($customizedDatas.$productId.$productAttributeId)}true{else}false{/if}, "customizedDatas":[ {if isset($customizedDatas.$productId.$productAttributeId[$product.id_address_delivery])} {foreach from=$customizedDatas.$productId.$productAttributeId[$product.id_address_delivery] key='id_customization' item='customization' name='customizedDatas'}{ldelim} {* This empty line was made in purpose (product addition debug), please leave it here *} "customizationId": {$id_customization}, "quantity": "{$customization.quantity}", "datas": [ {foreach from=$customization.datas key='type' item='datas' name='customization'} {ldelim} "type": "{$type}", "datas": [ {foreach from=$datas key='index' item='data' name='datas'} {ldelim} "index": {$index}, "value": "{Tools::nl2br($data.value|addslashes|replace: '\\\'':'\'')}", "truncatedValue": "{Tools::nl2br($data.value|truncate:28:'...'|addslashes|replace: '\\\'':'\'')}" {rdelim}{if !$smarty.foreach.datas.last},{/if} {/foreach}] {rdelim}{if !$smarty.foreach.customization.last},{/if} {/foreach} ] {rdelim}{if !$smarty.foreach.customizedDatas.last},{/if} {/foreach} {/if} ] {rdelim}{if !$smarty.foreach.products.last},{/if} {/foreach}{/if} ], "discounts": [ {if $discounts}{foreach from=$discounts item=discount name='discounts'} {ldelim} "id": "{$discount.id_discount}", "name": "{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|addslashes|replace:'\\\'':'\''}", "description": "{$discount.description|addslashes|replace:'\\\'':'\''}", "nameDescription": "{$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|addslashes|replace:'\\\'':'\''}", "code": "{$discount.code}", "link": "{$link->getPageLink("$order_process", true, NULL, "deleteDiscount={$discount.id_discount}")|escape:'html'}", "price": "{if $priceDisplay == 1}{convertPrice|html_entity_decode:2:'UTF-8' price=$discount.value_tax_exc}{else}{convertPrice|html_entity_decode:2:'UTF-8' price=$discount.value_real}{/if}", "price_float": "{if $priceDisplay == 1}{$discount.value_tax_exc}{else}{$discount.value_real}{/if}" {rdelim} {if !$smarty.foreach.discounts.last},{/if} {/foreach}{/if} ], "shippingCost": "{$shipping_cost|html_entity_decode:2:'UTF-8'}", "shippingCostFloat": "{$shipping_cost_float|html_entity_decode:2:'UTF-8'}", {if isset($tax_cost)} "taxCost": "{$tax_cost|html_entity_decode:2:'UTF-8'}", {/if} "wrappingCost": "{$wrapping_cost|html_entity_decode:2:'UTF-8'}", "nbTotalProducts": "{$nb_total_products}", "total": "{$total|html_entity_decode:2:'UTF-8'}", "productTotal": "{$product_total|html_entity_decode:2:'UTF-8'}", {if isset($errors) && $errors} "hasError" : true, "errors" : [ {foreach from=$errors key=k item=error name='errors'} "{$error|addslashes|html_entity_decode:2:'UTF-8'}" {if !$smarty.foreach.errors.last},{/if} {/foreach} ] {else} "hasError" : false {/if} {rdelim} ajax-cart.js var min = this.name.indexOf(';', 10); var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name); var name_short = this.name.substring(0, 100) + '...'; content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + this.name + '</a>'; blockcart.tpl <a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|escape:'html'}" title="{$product.name|escape:html:'UTF-8'}"> {$product.name|truncate:15:'...'|escape:html:'UTF-8'}</a> Link to comment Share on other sites More sharing options...
CartExpert.net Posted December 29, 2013 Share Posted December 29, 2013 var name = this.name.substring(0, 30) + '...'; 'name' is supposed to be the long name, yet you are truncating it! These two lines: var name = this.name.substring(0, 30) + '...';var name_short = this.name.substring(0, 30) + '...'; will give the same result, like: x = 2+2 y = 2+2 First, you need to remove the truncation on the name in the two tpl files (blockcart-json.tpl and blockcart.tpl) Second, you need to have a truncated version of the name in the javascript file, so use only var name_short = this.name.substring(0, 30) + '...'; Display short name in the <a> tag and put this.name in title. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 (edited) Yet works. But after reloading the page it wrong again. var min = this.name.indexOf(';', 10); var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name); var name_short = this.name.substring(0, 12) + '...'; content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name_short + '</a>'; Edited December 29, 2013 by tozi (see edit history) Link to comment Share on other sites More sharing options...
tozi Posted December 29, 2013 Author Share Posted December 29, 2013 Far I have solved it using CSS, but I would be happy if it modified the script. 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