Page 1 of 1

How to enable HTML in product attribute

Posted: Sun Oct 02, 2011 1:59 pm
by r94ever
Hi all,

I hava a question about editing Opencart source code that how to enable HTML code in Product Attribute when add or edit any product? I'm using Opencart 1.5.1.3

Thanks and sorry for my English! :)

Re: How to enable HTML in product attribute

Posted: Fri Nov 25, 2011 4:48 am
by salehjoon
Did you figure out how to do this? I need to do the exact same thing.

Re: How to enable HTML in product attribute

Posted: Tue Nov 29, 2011 1:12 pm
by salehjoon
A solution for this was suggested by Simon. I'm just re-posting it:

edit: admin/model/catalog/product.php

find 2 X occurrences of

Code: Select all

foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {
add after both occurrences

Code: Select all

$product_attribute_description['text'] = html_entity_decode($product_attribute_description['text'], ENT_QUOTES, 'UTF-8');

Re: How to enable HTML in product attribute

Posted: Thu Mar 15, 2012 8:08 am
by rwalker
Did not work in 1.5.1.2

Re: How to enable HTML in product attribute

Posted: Thu Mar 15, 2012 12:23 pm
by MissLiss
I'd also like this feature as well as be able to add an image of the attribute.

Re: How to enable HTML in product attribute

Posted: Thu Mar 15, 2012 1:47 pm
by qahar
What you need to do is not put the html_entity_decode() on admin, but on the front template.
Assuming you have an product attribute called "link", on front template (.tpl):

Code: Select all

    <?php echo html_entity_decode($attribute['link']); ?>
For the complete tuts, you can read here Product Attribute as Additional Info

Re: How to enable HTML in product attribute

Posted: Thu Jun 21, 2012 10:50 am
by mattalt
MissLiss wrote:I'd also like this feature as well as be able to add an image of the attribute.
Hi! Were you able to solve this? I´d also like to add an image.

Re: How to enable HTML in product attribute

Posted: Thu Jun 21, 2012 5:11 pm
by qahar
With my code above you can put the image manually:

Code: Select all

<img src="image/data/your-image.jpg" alt="alternatif text" />

Re: How to enable HTML in product attribute

Posted: Thu Jan 10, 2013 7:15 am
by Horhecart
This works great! TY qahar

Re: How to enable HTML in product attribute

Posted: Sat May 03, 2014 12:18 am
by labeshops
This no longer works in 1.5.6.x - any idea how to fix???

I tried http://www.opencart.com/index.php?route ... earch=html which works if I resave every single product, but that is obviously not practical with over 6000 products!

Re: How to enable HTML in product attribute

Posted: Tue May 06, 2014 11:28 pm
by labeshops
qahar wrote:What you need to do is not put the html_entity_decode() on admin, but on the front template.
Assuming you have an product attribute called "link", on front template (.tpl):

Code: Select all

    <?php echo html_entity_decode($attribute['link']); ?>
For the complete tuts, you can read here Product Attribute as Additional Info
Okay, this worked for me. I edited product.tpl changing:

Code: Select all

<td><?php echo $attribute['text']; ?></td>
to

Code: Select all

<td><?php echo html_entity_decode($attribute['text']); ?></td>
Thanks qahar!

Re: How to enable HTML in product attribute

Posted: Wed Jul 16, 2014 2:15 am
by sidalex
^^
but when i do compare my products , it shows plain html on the compare page :
Image

any help ?

Re: How to enable HTML in product attribute

Posted: Wed Jul 16, 2014 6:44 am
by labeshops
edit catalog/controller/product/compare.php

find:

Code: Select all

foreach ($attribute_groups as $attribute_group) {
		foreach ($attribute_group['attribute'] as $attribute) {
			$attribute_data[$attribute['attribute_id']] = $attribute['text'];
		}
	}
change to:

Code: Select all

foreach ($attribute_groups as $attribute_group) {
		foreach ($attribute_group['attribute'] as $attribute) {
			$attribute_data[$attribute['attribute_id']] = html_entity_decode($attribute['text']);
		}
	}

Re: How to enable HTML in product attribute

Posted: Wed Jul 16, 2014 10:48 am
by sidalex
thanks dude :) it worked :-*

Re: How to enable HTML in product attribute

Posted: Wed Jul 16, 2014 7:37 pm
by labeshops
Lol not a dude, but no problem. Glad it helped :)

Re: How to enable HTML in product attribute

Posted: Wed Oct 03, 2018 8:36 pm
by shohag0910
my opencart version 3.0.2.0 how to implement please give instruction