Too many <br/> in address textarea

  • Posts: 2143
  • Thank you received: 747
9 years 2 months ago #214134

-- url of the page with the problem -- : local
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.4
-- PHP version -- : 5.5.3

Hi,

I need to use text area fields in addresses. If I do, the HTML output has double <br/> in between the lines of textarea content, like e.g.

Regular Text Field
<br/>
Textarea Line 1
<br/>
<br/>
Textarea Line 2
<br/>
<br/>
Textarea Line 3
<br/>
Regular Text Field

I looked into classes/address.php, and now I know where the usual <br/> is coming from, but I'm not clever enough to get rid of the second one in between textarea content lines...

Can you help, please?
If it's from "outside HikaShop", perhaps it makes sense to amend the HikaShop code, so the regular <br/> separating fields doesn't get applied to textarea content?

Thanks!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #214135

Hi,

Try to change the line:

$html = str_replace("\n\n","\n",trim(str_replace("\r\n","\n", trim(preg_replace('#{(?:(?!}).)*}#i','',$html))),"\n"));
to:
$html = str_replace("\n\n","\n",str_replace("\n\n","\n",trim(str_replace("\r\n","\n", trim(preg_replace('#{(?:(?!}).)*}#i','',$html))),"\n")));
in the file administrator/components/com_hikashop/classes/address.php

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

  • Posts: 2143
  • Thank you received: 747
9 years 2 months ago #214188

Thanks Nicolas,

But unfortunately it doesn't change anything... :(

Other ideas very welcome!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 2 months ago #214235

Then, a few lines below, change the line:
return $html;
to:
return str_replace('<br/><br/>','<br/>',$html);

The following user(s) said Thank You: lousyfool

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

  • Posts: 2143
  • Thank you received: 747
9 years 2 months ago #214281

Almost, Nicolas, almost...

But damn close, indeed. While your line wouldn't work as is, I first tried around a bit because generally all sorts of replacement would work, of course, just '<br/><br/>' wouldn't do anything at all, no matter what.

Finally, nl2br came first to mind, then onto my (googled) screen. Some more trial and error, and here is the only combo of line breaks that works (note the extra space):

return str_replace('<br /><br/>','<br/>',$html);

Oh well, what a space more or less can do. Also note, I have no proof that it's due to nl2br, I'm just saying that after looking this up a lightbulb went on in my head and I started playing with spaces... and there it was. After juggling it for a good hour, here's one more snippet I won't forget so soon, lol!

Thanks for your patience and for getting me not only "on the way" but all the way with only a single space left to the finish line, hehe! :cheer:


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

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

Time to create page: 0.060 seconds
Powered by Kunena Forum