Hi!
Sorry for my bad english)
I got an annoying client, who wants that the product name is displayed in two lines.
Simply can not break product name in two lines.
I thought to add a field in the database (such as "product_name_prefix"), but then I realized that then (with my PHP skills:)) I can not fix the breadcrumbs, aliases, the cart, other modules, etc.
Thanks for any help or idea.
Hello,
Yes using some PHP to your overridden files, could be like this:
<?php
$title_length= strlen($product->product_name);
echo wordwrap($product->product_name, floor($title_length / 2),"<br />\n");
?>
Regards
Thanks a lot, bytelord!
Interesting variant, not perfect but pretty good :)
Hello,
You can make it to support hyper-nation but i think this is the best you could done if you want the product title to devide it in two lines, otherwise use some CSS to make the default height of the div that places the title equal to 2 lines.
Regards
I adjusted a bit the "coefficient" - for my tasks - perfect.
Another: some of the products contain " character (eg Espresso "Premium"), here is the situation easier. I'm using a simple regexp
$regex = '/(\s")/';
if (preg_match($regex, $product->product_name)) {
$product->product_name = preg_replace($regex, "<br/>\n\"", $product->product_name);
} else {
...your code;
}
Thanks for the inspiration!)
I could say i prefer preg_match/replace also :)
Well done :)
Regards
hey, guys, I am looking for a solution on this subject but this doesn't work as I wish. Did you make it work and if yes what is the code? The one you have mentioned brakes every word into a new line. I just want to break it to 2 lines. I really have to fix it, my client is such a b..ch. Thanks.