| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Truncate product title in XC5 | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
Truncate product title in XC5
Does anybody know how to truncate the product title in XC5? Thanks in advance
I am talking about the /default/en/items_list/product/parts/common_product_name.tpl
__________________
Richard Ultimate 5.4 testing |
|||||||||
#2
|
|||||||||
|
|||||||||
Re: Truncate product title in XC5
Probably best done in PHP. I can't find any reference or example of a title being truncated in a template.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#3
|
|||||||||
|
|||||||||
Re: Truncate product title in XC5
Ah ok thanks mike, I was wondering the same thing, shame it can't be done in the template like before
__________________
Richard Ultimate 5.4 testing |
|||||||||
|
#4
|
|||||||||
|
|||||||||
Re: Truncate product title in XC5
Okay here you go.
I decorated XLite/Model/Product (though there might be a better class, I just went straight to the source) Added this method: Code:
And then refernced it in a template like this: Code:
There might be a more flexible truncation function in PHP, but substr() is the only one I am familiar with. Quick search just turned this up: http://stackoverflow.com/questions/9219795/truncating-text-in-php So maybe substr is the best way. If you need more control look at the second option there with a pretty little truncate function.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
|
#5
|
|||||||||
|
|||||||||
Re: Truncate product title in XC5
Quote:
With Smarty(XC4 template engine), we got some of that separation, but not nearly enough. I'm not a mind reader, but if I put myself in the position of the devs behind Flexy (XC5 template engine); I can see them being determined to not let Flexy turn into the mess that Smarty did. Smarty gave designers too much power. And so rather than learn some PHP or bring in a dev, they just implemented some code in Smarty that "took care of it". Even if "taking care of it" meant 20 nested foreach loops. This is the better way. But the learning curve is frightful for some. A real world example of how this is better, even from a designer's standpoint: Now you have truncated the product name in 20 different templates with a Smarty call to {$product.name|truncate:30:"...":true}. And your client says "What the heck are those three dots at the end? I want those removed". You now have 20 edits to make. With a PHP method/function it's just one change. Yeah I may be reaching with this example, but it demonstrates the point perhaps.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#6
|
|||||||||
|
|||||||||
Re: Truncate product title in XC5
@Mike, here is a way of truncating a string and having full words:
http://stackoverflow.com/a/79986/4634288
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
|
|
|||
X-Cart forums © 2001-2020
|