I've beaten my head against the wall for three days and nights over this problem, but I can't seem to figure it out. Maybe one of the more experienced participants in this forum can answer this question (I can't seem to find an answer anywhere on this forum or on the Hypermart site).
Basically, I've incorporated JPDeni's excellent external text upload mod, but now I'd like to be able to save the contents of not just one but three textareas as external text files. Everything works except when I try to modify a record, in which case the textareas don't get populated with any text.
To combine the three textareas, I added the following line to both "sub add_record" and "sub modify_record" in "db.cgi."
$in{'text'} = "$in{'narrative'}\|$in{'teaser'}\|$in{'article'}";
This works great. The $in{'text'} gets written correctly to the external file with pipe delimiters. In order to separate the three fields again for display, I added the following to "html_record" in my .pl file:
open (TEXT, "<$save_text_dir/$rec{$db_key}.txt") or &cgierr("error in displaying record. unable to open text file $save_text_dir/$rec{$db_key}.txt\nReason: $!");
@text = <TEXT>;
close TEXT;
$rec{'text'} = join "",@text;
@Splitter = split /\|/, $rec{'text'}; # Break up the text file into separate values. (The use of @Splitter was intentional.)
$rec{'narrative'} = $Splitter[0];
$rec{'teaser'} = $Splitter[1];
$rec{'article'} = $Splitter[2];
Again, everything diplays correctly.
The only problem is, when I try to modify a record, the three textareas show up as blank. Here's the code I added to "sub html_record_form" in my .pl file:
if ($in{'modify'}) {
open (TEXT, "<$save_text_dir/$rec{$db_key}.txt") or &cgierr("error in html_record_form. Unable to open text file $save_text_dir/$rec{$db_key}.txt\nReason: $!");
@text = <TEXT>;
close TEXT;
$in{'text'} = join "",@text;
@Splitter = split /\|/, $in{'text'};
$Splitter[0] = $in{'narrative'};
$Splitter[1] = $in{'teaser'};
$Splitter[2] = $in{'article'};
}
What could be wrong here? If anyone wants to take a crack at this I would REALLY appreciate it! I've uploaded my files as text files to the following location: http://www.fianchetto.com/dbman
Thanks--Hal
Basically, I've incorporated JPDeni's excellent external text upload mod, but now I'd like to be able to save the contents of not just one but three textareas as external text files. Everything works except when I try to modify a record, in which case the textareas don't get populated with any text.
To combine the three textareas, I added the following line to both "sub add_record" and "sub modify_record" in "db.cgi."
$in{'text'} = "$in{'narrative'}\|$in{'teaser'}\|$in{'article'}";
This works great. The $in{'text'} gets written correctly to the external file with pipe delimiters. In order to separate the three fields again for display, I added the following to "html_record" in my .pl file:
open (TEXT, "<$save_text_dir/$rec{$db_key}.txt") or &cgierr("error in displaying record. unable to open text file $save_text_dir/$rec{$db_key}.txt\nReason: $!");
@text = <TEXT>;
close TEXT;
$rec{'text'} = join "",@text;
@Splitter = split /\|/, $rec{'text'}; # Break up the text file into separate values. (The use of @Splitter was intentional.)
$rec{'narrative'} = $Splitter[0];
$rec{'teaser'} = $Splitter[1];
$rec{'article'} = $Splitter[2];
Again, everything diplays correctly.
The only problem is, when I try to modify a record, the three textareas show up as blank. Here's the code I added to "sub html_record_form" in my .pl file:
if ($in{'modify'}) {
open (TEXT, "<$save_text_dir/$rec{$db_key}.txt") or &cgierr("error in html_record_form. Unable to open text file $save_text_dir/$rec{$db_key}.txt\nReason: $!");
@text = <TEXT>;
close TEXT;
$in{'text'} = join "",@text;
@Splitter = split /\|/, $in{'text'};
$Splitter[0] = $in{'narrative'};
$Splitter[1] = $in{'teaser'};
$Splitter[2] = $in{'article'};
}
What could be wrong here? If anyone wants to take a crack at this I would REALLY appreciate it! I've uploaded my files as text files to the following location: http://www.fianchetto.com/dbman
Thanks--Hal