Post by salehjoon » Mon Nov 28, 2011 4:33 pm

Is there a way to put a clickable link in product attributes? I tried to put a link to an image in the attribute but the result is a text displaying the html code.
Last edited by salehjoon on Tue Nov 29, 2011 1:09 pm, edited 1 time in total.

New member

Posts

Joined
Sun Nov 20, 2011 12:17 pm

Post by wolfsteritory » Mon Nov 28, 2011 6:32 pm

v 1.5.1

i want to enable html formatting for different product attributes

what do i have to modify & where ?

Here Are Your Options :
1st Option: Web3DesignStudio
More Options ? - What More Do You Need ? !


User avatar
New member

Posts

Joined
Sun Feb 01, 2009 2:08 am

Post by uksitebuilder » Tue Nov 29, 2011 12:14 am

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');

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by salehjoon » Tue Nov 29, 2011 3:29 am

I did what you said but it didn't work.

first occurrence

Code: Select all

		if (isset($data['product_attribute'])) {
			foreach ($data['product_attribute'] as $product_attribute) {
				if ($product_attribute['attribute_id']) {
					$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "'");
					
					foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {				
//added the following line to enable html in product attribute description	
					$product_attribute_description['text'] = html_entity_decode($product_attribute_description['text'], ENT_QUOTES, 'UTF-8');		
//end of the code for adding html text.
						$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_id . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" .  $this->db->escape($product_attribute_description['text']) . "'");
					}
				}
			}
		}
second occurrence:

Code: Select all

		if (!empty($data['product_attribute'])) {
			foreach ($data['product_attribute'] as $product_attribute) {
				if ($product_attribute['attribute_id']) {
					$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "'");
					
					foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {	
//added the following line to enable html in product attribute description	
					$product_attribute_description['text'] = html_entity_decode($product_attribute_description['text'], ENT_QUOTES, 'UTF-8');		
//end of the code for adding html text.						
						$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_id . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" .  $this->db->escape($product_attribute_description['text']) . "'");
					}
				}
			}
		}

New member

Posts

Joined
Sun Nov 20, 2011 12:17 pm

Post by dony_b » Tue Nov 29, 2011 3:55 am

uksitebuilder wrote: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');
Oh thats cool to add a unique link for each product ....

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by uksitebuilder » Tue Nov 29, 2011 6:52 am

it should work salejoon

I tested it before posting (something I very rarely do lol)

Your code looks correct too, so not sure what else to suggest.

Maybe you have vqmod installed with useCache set to True.

If so, clear your vqmod/vqcache folder

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by dony_b » Tue Nov 29, 2011 7:19 am

Works for me

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by salehjoon » Tue Nov 29, 2011 1:08 pm

Okay it worked. I'm not sure what went wrong there. I think I had two different product.php files open and uploaded the wrong one. Thank you very much!

New member

Posts

Joined
Sun Nov 20, 2011 12:17 pm

Post by PlusCybernet » Thu Jan 26, 2012 4:04 pm

@ uksitebuilder ... Thanks for this information.

User avatar
Active Member

Posts

Joined
Sun Dec 25, 2011 12:01 pm

Post by thehumancpu » Mon Mar 05, 2012 4:38 am

I think 1.5.2 broke this mod. I had it working, updated to 1.5.2, then re-did mod to the file and does not function.

New member

Posts

Joined
Mon Oct 19, 2009 10:59 am

Post by Phil_L » Sun Nov 25, 2012 8:47 pm

uksitebuilder wrote: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');

would be wicked if this was some sort of Vqmod or even in the next iteration of the core. :-))

Home Study and Online Courses | Breakwater Brewing Co.


New member

Posts

Joined
Thu May 31, 2012 12:23 am


Post by rwalker » Tue Jan 21, 2014 7:06 am

uksitebuilder wrote: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');
Thanks for this works well on 1.5.1!

I'm attempting to show the attribute next to the price following this thread: http://forum.opencart.com/viewtopic.php?f=139&t=50476 this is what I've got:

Code: Select all

<!-- Start Additional Info -->
  <?php if ($attribute_groups) { ?>
    <?php foreach ($attribute_groups as $attribute_group) { ?>
      <?php if ($attribute_group['name'] == 'Product Info') { ?>
        <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
          <span><?php echo $attribute['name']; ?></span> <?php echo html_entity_decode($attribute['text'], ENT_QUOTES, 'UTF-8'); ?><br />
        <?php } ?>
      <?php } ?>
    <?php } ?>
  <?php } ?>
  <!-- End Additional Info -->
It doesn't want to show. Am I missing something?

Thanks,

Rian

Discount Golf Clubs and Golf Equipment - Powered by Opencart


New member

Posts

Joined
Fri Jul 01, 2011 8:14 am

Post by masterbeta » Thu Jan 21, 2016 6:54 pm

for reference on 2.1.0.1 for options descriptions to make links the code in 2 places on options.php is this:

Code: Select all

$option_value_description['name'] = html_entity_decode($option_value_description['name'], ENT_QUOTES, 'UTF-8');
edit***

i've also added it in a 3rd place under the edit function...

however, when going to edit the option, i cannot edit the html code - so i have to delete the entire option (and remove from product first) and re-add a new one with code.... a bit tedious, unless someone else has an idea?

thanks in advance

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by sedra » Fri Aug 23, 2019 7:51 pm

uksitebuilder wrote:
Tue Nov 29, 2011 12:14 am
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');
thank you.
it works beatifully on OC 3.0.2.0

New member

Posts

Joined
Thu Jan 04, 2018 8:14 pm
Who is online

Users browsing this forum: No registered users and 17 guests