Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Converting line breaks to BR tags in description

Quote Reply
Converting line breaks to BR tags in description
Heya,

I'm trying to get my nph-build to convert all line breaks to BR tags. The goal is to allow people to enter very long descriptions, and preserve the formatting. So, where ever they hit the enter key in the description field (a line break in the data file) a BR tag needs to be entered to format the description accordingly.
(same as what this forum software does!)

I would prefer not to enter any BR tags in $db_file_name but do the substitution when the static pages are being build.

I've tried to insert this line in nph-build.cgi on a few places where I though made sense but to no avail:

Code:
$db_file_name =~ s/\n/<BR>/gi;


Am I approaching this in the correct way? My PERL skills are very suspect. Any help will be appreciated.

Safe swoops
Sangiro

www.dropzone.com

Quote Reply
Re: Converting line breaks to BR tags in description In reply to
This has been discussed more than once in the Modification Forum....

What you need to do is add the following codes in your sub site_html_link routine in either site_html.pl or site_html_templates.pl depending if you are using templates or not:

Code:
$rec{'FieldName'} =~ s/\n/<BR>/g;

Change FieldName with the name of your fields...

-OR- simply use the following codes:

Code:
foreach $column (@db_cols) {
$rec{$column} =~ s/\n/<BR>/g;
}

BTW: This is a more appropriate question to be posted in the LINKS Modification Forum since it deals with code hacking.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.