Jump to content

Adding HTML tag in Name of product


Recommended Posts

Hey all.

 

I know that when you create a product i presta it says something about how you cant use characters like " <>;:" etc. in Product Names

 

Is there anyway to make product names have line breaks? I want to use <br> in some of my names to make them split at a certain word.

 

Any advise?

Link to comment
Share on other sites

it isn't possible due to the the object definition (product class)

'name' =>	   array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),

 

moreover, many modules like homefeatured etc. remove the html tags from the name variable

Link to comment
Share on other sites

  • 3 months later...
  • 6 months later...

Hallo...

 

I'm looking for the same kind of solution for a shop I'm building...

 

In this case the products are movie titles and it can happens that the same title comes in different editions.

 

let's make an example:

 

I have two editions of the same movie:

1) X-Men: Final Conflict - DVD Edition

2) X-Men: Final Conflict - Blu-Ray Collector's Edition

 

Now... in grid list (both in home page or category pages, etc. the title is written on one single line, while the best solution should be:

 

1)

X-Men: Final Conflict

DVD Edition

 

2)

X-Men: Final Conflict

Blu-Ray Collector's Edition

 

 

Sometimes it's even worst, since I have very loooong title, like this:

 

Full Metal Panic: The Second Raid  Intégrale DVD + OAV - Edition Collector

 

 

As you can see, in this last case, the way the text is formatted is ugly and I'd need something like:

 

Full Metal Panic:

The Second Raid

Intégrale DVD + OAV

Edition Collector

 

 

Any idea? Maybe I can put some details in the short description...

 

In the previous examples it would be:

 

TITLE: X-Men: Final Conflict

SH. DESC.: DVD Edition

 

TITLE: X-Men: Final Conflict

SH. DESC.: Blu-Ray Collector's Edition

 

TITLE: Full Metal Panic: The Second Raid

SH. DESC.: Intégrale DVD + OAV - Edition Collector

 

But depending to which theme I use, the short description doesn't appear in the grid view of Home Page Featuted or New products...

 

 

 

I'm getting really mad and any help would be appreciated...

Link to comment
Share on other sites

Hello there

 

Iam also interested about that. Very useful hack. Do I need(or can I) replace the "{$product->name|escape:'htmlall':'UTF-8'}" to

{$product->name|replace:' - ':'<br/>'} in the product.tpl? Iam using prestashop1.5.5

 

Thanks in advance of any replies.

Link to comment
Share on other sites

  • 1 year later...

Your product name should be set like: My product - new line

 

If you want this hack in product list:

https://github.com/PrestaShop/PrestaShop/blob/1.6.1.x/themes/default-bootstrap/product-list.tpl#L118

{$product.name|replace:' - ':'<br/>'}

You could also add the |truncate:45 if you want to limit the characters, but don't add the escape parameter.

 

In product page:

https://github.com/PrestaShop/PrestaShop/blob/1.6.1.x/themes/default-bootstrap/product.tpl#L158

If you want the product name split on new line use the code from vekia:

{$product->name|replace:' - ':'<br/>'}

Otherwise if you only want to display the name of the product without the ' - ' and no new line use:

{$product->name|replace:' - ':' '}

Warning!

The code above treats only the display of product list and product page but there are many pages on which the product name is displayed and it will include the dash.

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...