News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Line break in product name or product name with "prefix"

Started by andrew.overlord, December 16, 2012, 23:51:52 PM

Previous topic - Next topic

andrew.overlord

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.

bytelord

Hello,

Yes using some PHP to your overridden files, could be like this:

<?php
$title_length
strlen($product->product_name);
echo 
wordwrap($product->product_namefloor($title_length 2),"<br />\n");
?>


Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

andrew.overlord

Thanks a lot, bytelord!
Interesting variant, not perfect but pretty good  :)

bytelord

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
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

andrew.overlord

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!)

bytelord

I could say i prefer preg_match/replace also :)

Well done  :)

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

banik78

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.