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:
- 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.
- 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.
- 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