Jump to content

[SOLVED] product short description field not displaying html


Recommended Posts

Do you mean on the product listings or on the product page? The link should appear on the product page, but it won't appear on the product listings because Prestashop strips all HTML code from the short description. To stop Prestashop stripping the HTML code, change line 10 of product-list.tpl in your theme's directory from:


<a href="{$product.link|escape:'htmlall':'UTF-8'}">{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}



to:


<a href="{$product.link|escape:'htmlall':'UTF-8'}">{$product.description_short|truncate:360:'...'|escape:'htmlall':'UTF-8'}

  • Like 1
Link to comment
Share on other sites

Yes, I was referring to the product list page where the short_description box can display a brief description. Thanks for the code change, I'll give that a shot.

Just wondering why the paragraph tag "

" is added in the admin product short_description html code. Is that something built into the TinyMCE plugin? Or is there a way to force the

out of there?

Thanks very much for the quick reply!

Andy

Link to comment
Share on other sites

Try changing line 10 of product-list.tpl in your theme's directory to:


<a href="{$product.link|escape:'htmlall':'UTF-8'}">{if $product.description_short|substr:0:3 == '
'}{$product.description_short|substr:3:-4|truncate:360:'...'}{else}{$product.description_short|truncate:360:'...'}{/if}



This code will check whether the first 3 characters of the description are <p>. If they are, it cuts off the first 3 and last 4 characters to remove the tags. If the description starts with another tag (like

  • ), it doesn't cut off any letters.
Link to comment
Share on other sites

Try changing line 10 of product-list.tpl in your theme's directory to:


<a href="{$product.link|escape:'htmlall':'UTF-8'}">{if $product.description_short|substr:0:3 == '
'}{$product.description_short|substr:3:-4|truncate:360:'...'}{else}{$product.description_short|truncate:360:'...'}{/if}



This did the trick, thanks!
I may however need to use html editor instead of wysiwyg to insert 'br' tags (to avoid double paragraphs), but it works.
Link to comment
Share on other sites

  • 2 months later...
  • 11 months later...
  • 1 month later...

Just an FYI: This does not seem to work in v.1.4.1.0.
Tried each of the solutions but HTML formatting is still thrown out in the product descriptions (when you first click on a category.) In the prouct detail page, HTML formatting is ok of course)

Link to comment
Share on other sites

  • 7 months later...

Hi rocky, I tried to remove

strip_tags:'UTF-8'

from the product list.tpl and it is quit working, but instead of "showing" the brake in FO, it will shows the code for it... For example:

 

Chirurgická ocel, cz sklo<br />Naušnice, přívěsek

 

So I have html tag in short description now, but it is as normal text... so without wanted effect :)))))

Can you help with this please?

Link to comment
Share on other sites

  • 1 month later...

Hi Simberak or anyone else,

 

Can you expand on this. I am unable to get the short description to display on the product list page. I want to use the <br> tags from my short description is a small list of features that look jumbled if they are all on the same line.

 

This is what my product list description looks like:

<div class="red_box"><strong>Name:</strong> Product name <strong></strong></div> <div class="red_box"><strong>Synonyms:</strong> Synonym 1, Synonym 2, Synonym 3</div> <div class="red_box"><strong>Number:</strong> <span class="st">47554640</span><strong></strong></div> <div...

 

I would like it to look like:

Name: Product Name

Synonyms: Synonym 1, Synonym 2, Synonym 3

Number: 47554640

 

This is what is currently displaying that in my theme's product-list.tpl:

<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|truncate:360:'...'|escape:'htmlall':'UTF-8'}">{$product.description_short|truncate:360:'...'|escape:'htmlall':'UTF-8'}</a></p>

Link to comment
Share on other sites

The code is not displaying right. Here it is:

 

Hi Simberak or anyone else,

 

Can you expand on this. I am unable to get the short description to display on the product list page. I want to use the <br> tags from my short description is a small list of features that look jumbled if they are all on the same line.

 

This is what my product list description looks like:

<div class="red_box"><strong>Name:</strong> Product name <strong></strong></div> <div class="red_box"><strong>Synonyms:</strong> Synonym 1, Synonym 2, Synonym 3</div> <div class="red_box"><strong>Number:</strong> <span class="st">47554640</span><strong></strong></div> <div...

 

I would like it to look like:

Name: Product Name

Synonyms: Synonym 1, Synonym 2, Synonym 3

Number: 47554640

 

This is what is currently displaying that in my theme's product-list.tpl:

<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|truncate:360:'...'|escape:'htmlall':'UTF-8'}">{$product.description_short|truncate:360:'...'|escape:'htmlall':'UTF-8'}</a></p>

Link to comment
Share on other sites

The code is not displaying right. Here it is:

 

<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|truncate:360:'...'|escape:'htmlall':'UTF-8'}">{$product.description_short|truncate:360:'...'|escape:'htmlall':'UTF-8'}</a></p>

 

Link to comment
Share on other sites

Nevermind. Figured it Out. To show the short description on category pages as it appears on your product page. Use this:

<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|truncate:360:'...'|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}">{$product.description_short|truncate:360:'...'}</a></p>
Link to comment
Share on other sites

  • 1 year later...

In order to allow html formatting in my short description, I've changed my product-list.tpl

from

<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}</a></p>

 

to

 

<p class="product_desc">
   <a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|truncate:360:'...'}</a>
   </p>

 

However, it seems that extra <p> tags get inserted when I do this.

Is it possible to avoid this, as it makes the visual formatting of the product list page to be off.

 

Rumor has it that TinyMCE is adding these extra <p> tags. Is ti possible to stop it from doing that?

 

Many thanks.

Link to comment
Share on other sites

  • 1 year later...
  • 5 months later...

Find this line in product-list.tpl in main directory of your theme:

<p class="product-desc" itemprop="description">
{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}
</p>

 

and change it to:

<div class="product-desc" itemprop="description">
{$product.description_short|truncate:360:'...'}
</div>

 

 

Then navigate to your theme's js folder and in global.js file find:

html += '<p class="product-desc">'+ $(element).find('.product-desc').html() + '</p>';

 

and change it to:

html += '<div class="product-desc">'+ $(element).find('.product-desc').html() + '</div>';

 

This first line should be there twice, change both.

Link to comment
Share on other sites

×
×
  • Create New...