Page 1 of 1

[SOLVED] add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 3:02 am
by ianhaney50
I've got a option name called Front Screen (Glass Only) for the radio type options and I would like to add a line break or br html tag to the name so it would look like the following on the product page
Front Screen
(Glass Only)
£price

Is that possible to do in opencart 3.0.4.0?

Re: add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 3:07 am
by khnaz35
Front Screen<br>(Glass Only)

Re: add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 3:10 am
by ianhaney50
khnaz35 wrote:
Wed Jun 25, 2025 3:07 am
Front Screen<br>(Glass Only)
I tried that but on the product page on the front end, it shows <br> within the text instead of putting it on a new line

Re: add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 3:44 am
by khnaz35
Try
{{ option_value.name|raw }}

Re: add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 5:01 am
by ianhaney50
khnaz35 wrote:
Wed Jun 25, 2025 3:44 am
Try
{{ option_value.name|raw }}
Thank you, I tried that but still got Front Screen<br>(Glass Only)

Re: add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 6:02 pm
by paulfeakins
ianhaney50 wrote:
Wed Jun 25, 2025 5:01 am
Thank you, I tried that but still got Front Screen<br>(Glass Only)
You won't be able to get the < and > past the PHP htmlentities() type functions. You'll need to modify the code.

Re: add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 7:09 pm
by ianhaney50
paulfeakins wrote:
Wed Jun 25, 2025 6:02 pm
ianhaney50 wrote:
Wed Jun 25, 2025 5:01 am
Thank you, I tried that but still got Front Screen<br>(Glass Only)
You won't be able to get the < and > past the PHP htmlentities() type functions. You'll need to modify the code.
What file would I need to modify and what code would I need to look for please?

Re: add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 7:25 pm
by ADD Creative
You could try something like the following.

Code: Select all

{{ option_value.name|replace({'(': '<br>('}) }}

Re: add line break or html tags to option value name input field

Posted: Wed Jun 25, 2025 10:27 pm
by ianhaney50
ADD Creative wrote:
Wed Jun 25, 2025 7:25 pm
You could try something like the following.

Code: Select all

{{ option_value.name|replace({'(': '<br>('}) }}
Thank you, I worked it out a different way that looks to have worked, I changed the database to the following as it was putting <br> in the database as &amp;lt;br&amp;gt; so updated it using the following sql in phpmyadmin

Code: Select all

UPDATE oc_option_value_description
SET name = REPLACE(name, '&amp;lt;br&amp;gt;', '<br>')
WHERE name LIKE '%&amp;lt;br&amp;gt;%';
I then used the code

Code: Select all

{{ option_value.name|raw }}
It looks to have worked

Re: [SOLVED] add line break or html tags to option value name input field

Posted: Thu Jun 26, 2025 1:17 am
by khnaz35
Great!