Adding HTML code in attribute value?

  • stavros
  • Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #63188 by stavros
Adding HTML code in attribute value? was created by stavros
Hi I created my groups of attributes and added my values in each of the attribute.

I want to include some HTML code in the value of the attribute such as: instead of showing like this... LED: up to 150W, CFL: up to 150W, halogen: up to 600W, incandescent: up to 600W

to be:
LED: up to 150W<br/>
CFL: up to 150W<br/>
halogen: up to 600W<br/>
incandescent: up to 600W

also might include a click here after the value to link something!!

Can it be done, somehow?
Kind Regards,
Stavros.

Please Log in or Create an account to join the conversation.

  • Giang Dinh Truong
  • Offline
  • Administrator
  • Administrator
More
8 years 11 months ago #63216 by Giang Dinh Truong
Replied by Giang Dinh Truong on topic Adding HTML code in attribute value?
Hello Stavros,

Sorry, you can not add html code to the value of attribute values. It does not allow.

Sincerely, Giang

Please Log in or Create an account to join the conversation.

More
6 years 10 months ago #99640 by Antonio Grazioli
Replied by Antonio Grazioli on topic Adding HTML code in attribute value?
Sorry to resurrect this old post, but I needed to do the same...

actually, it should be possible by modifying products.php in /administrator/components/com_eshop/models

search for the lines
Code:
$attributeValue = JRequest::getVar('attribute_value_' . $langCode);
(there should be 2)

and change them to:
Code:
$attributeValue = JRequest::getVar('attribute_value_' . $langCode, '', 'post', 'string', JREQUEST_ALLOWRAW );


this will allow the inputboxes for attributes values NOT to be filtered in any way

Please Log in or Create an account to join the conversation.

  • Giang Dinh Truong
  • Offline
  • Administrator
  • Administrator
More
6 years 10 months ago #99660 by Giang Dinh Truong
Replied by Giang Dinh Truong on topic Adding HTML code in attribute value?
Hello Antonio,

It's fine if you can modify that to make it works as your requirement.

Sincerely, Giang

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #155554 by Julian Lilio
Replied by Julian Lilio on topic Adding HTML code in attribute value?
Hi Giang and Team,

I too have to resurrect this old thread as I have an absolute need to do the following:
  • Be able to put HTML tags on the attribute value
  • Be able to write a much longer text than 255 characters for the attribute value.
After several failed attempts, I was able to make it work with a very slight code change and using a 3rd party plugin, Sourcerer. I have documented what I did, so it can help others who are in a similar situation.

JoomDonation eShop: HTML code in attribute value field with text longer than 255 characters

The procedure below has been tested on the following environment:
  • Joomla 4.2.6
  • eShop 3.6.2
  • PHP 8.0.23
  • MySQL 8.0.23
Procedure:
  1. Install Regular Lab's Sourcerer free edition. Note that Sourcerer has the capability of using double square brackets i.e., [[]] to replace <> which is being stripped (i.e., filtered) by the input field.
  2. Modify the field "value" from the database table "_eshop_productattributedetails". Change it to type "text" (with no length so it can use a max of 65,535 characters) instead of "varchar" with a length of 255. This can easily be achieved with a tool like phpMyAdmin.
  3. Remove maxlength="255" the following files so they become similar to the following, respectively:

    administrator/components/com_eshop/views/product/tmpl/default_attributes.php - Line 64:
    <input class="input-xlarge form-control" type="text" name="attribute_value[]" value="<?php echo htmlentities($productAttribute->value); ?>" />

    administrator/components/com_eshop/views\product/tmpl/default_javascript.php - Line 170 (note: in my test, I didn't have to do this):
    html += '<input class="input-xlarge form-control" type="text" name="attribute_value[]" value="" />';
Examples:
Instead of doing this: {source}<strong>Text</strong>{/source}
Do this: {source}strongText/strong{/source}

Another example that will work too even if what's written on the input field is more than 255 characters (including the tags):
{source}strongulliThis is just a test to see if the the field will accept the total number of characters which was previously set at 255./strong - a href="[/color][url=https://www.synology.com/en-global/products/FS6400#specs][color=#2980b9]https://www.synology.com/en-global/products/FS6400#specs[/color][/url][color=#2980b9]" target="_blank"Complete Specification/a/lilibSecond line/b/li/ul{/source}

Recommendation: Include change in the eShop core (i.e, items 2 and 3 above).

Note: Doing this will have minimal effect on other areas, but will definitely prepare the attribute value to be longer than 255 characters. This is effective for many use cases, even without using HTML tags as enabled by the 3rd party plugin, Sourcerer.

References:
regularlabs.com/sourcerer/download
docs4.regularlabs.com/sourcerer/going-further/advanced

Note: The suggested workaround from joomdonation.com/forum/eshop-general-dis...ute-value.html#99640 of using 'raw' no longer works on Joomla 4.

I hope this helps.

Best regards

Julian
Attachments:

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #155555 by Julian Lilio
Replied by Julian Lilio on topic Adding HTML code in attribute value?
Sorry, I didn't realize earlier that the forum is using Markdown source, hence it stripped some of the square brackets on my example. I hope that those who will reference this will simply get it, i.e., to use double square open and double close brackets instead of the angle brackets.

Please Log in or Create an account to join the conversation.

Moderators: Giang Dinh Truong