Gossamer Forum
Home : Products : DBMan : Customization :

linking fileURL?

Quote Reply
linking fileURL?
Hi! I am having a problem getting the URL to display as a link in search results. The main portion of the URL does not change so I have made it a hidden field (FileURL). When the actual file name is added in the field FileName, I would like for it to append to the FileURL when displayed and be a link to the file. Help would be very much appreciated to identify what corrections are needed. Thanks!

%db_def = (

RecordID => [0, 'numer', -1, 8, 1, '', ''],
ImageName => [1, 'alpha', 35, 250, 0, '', '' ],
FileURL => [2, 'alpha', -1, 250, 1, '', '^http://IPADDRESS/FOLDER/'],
FileName => [3, 'alpha', 35, 250, 0, '', '' ],
LinkURL => [4, 'alpha', 40, 250, 0, 'http://', '^http://' ],
Height => [5, 'numer', 3, 3, 0, '', '' ],
Width => [6, 'numer', 3, 3, 0, '', '' ],
AltText => [7, 'alpha', 35, 250, 0, '', '' ]
);


at sub html_record, I have

$url{'LinkURL'} = $rec{'LinkURL'};
$url{'LinkURL'} =~ s/<\/?B>//g;
$url{'FileURL'} = $rec{'FileURL'};
$url{'FileURL'} =~ s/<\/?B>//g;

print qq|
<input type=hidden name="uid" value="$db_uid">
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">|;
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ImageName:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ImageName'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>FileName:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="$url{'FileURL'}$rec{'FileName'}">$url{'FileURL'}$rec{'FileName'}</a>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>LinkURL:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="$url{'LinkURL'}">$rec{'LinkURL'}</a>

- - - rest of table

Neither FileURL nor LinkURL display as links. FileURL does not display at all, LinkURL does display as text.

I am a true newbie on both db's and perl, please bear that in mind when replying. Thanks so much for taking the time to even read my request for help!


------------------
Ogie

We all have challenges in this life, how you deal with them can set you apart!
Quote Reply
Re: linking fileURL? In reply to
First of all, change the regexp you have:

Code:
$url{'LinkURL'} = $rec{'LinkURL'};
$url{'LinkURL'} =~ s/<\/?B>//g;
$url{'FileURL'} = $rec{'FileURL'};
$url{'FileURL'} =~ s/<\/?B>//g;

to the following:

Code:
$rec{'LinkURL'} =~ s/<\/?B>//g;
$rec{'FileURL'} =~ s/<\/?B>//g;

Change all the $url record hash codes to the following $rec.

Like the following:

Code:
$url{'LinkURL'}

to the following:

Code:
$rec{'LinkURL'}

Best of luck!

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited February 26, 2000).]
Quote Reply
Re: linking fileURL? In reply to
BTW: In order for this to work...You will have to turn off auto-generation and replace -1 for the minimum length column to 10 or something like that.

And you will have to manually add the hidden field for the field in the sub html_record_form.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: linking fileURL? In reply to
Thank you so much Eliot! The changes seem to have done the trick.

In View All, I noticed one record displayed as FileName: http://IPADDRESS/FOLDER/|FILENAME.jpg

See the pipe in there? Any ideas what could have caused that or how to prevent recurrence? Figured I'll just have to delete that record & re-enter it to correct this record. Would like to know how to prevent it again though.

BTW - I had this in sub html_record_form, is that what you meant by adding the field manually?
<input type="hidden" NAME="FileURL" VALUE="$rec{'FileURL'}">

Thanks again!

------------------
Ogie

We all have challenges in this life, how you deal with them can set you apart!
Quote Reply
Re: linking fileURL? In reply to
 Frown I just tried adding another sample record and the pipe is in there again. Any suggestions? Thanks!

------------------
Ogie

We all have challenges in this life, how you deal with them can set you apart!
Quote Reply
Re: linking fileURL? In reply to
Please copy your COMPLETE sub html_record_form routine.

Also, you should be using the following codes for printing the FileName:

Code:
<a href="$rec{'FileURL'}/$rec{'FileName'}">

I am assuming that you having people type in the following file name and extension:

Code:
FILENAME.jpg

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: linking fileURL? In reply to
Hi Eliot, thank you for your efforts on this! Yes, one of the input fields for adding a record is FILENAME.jpg.

Looking at the example you gave, the problem may be as simple as me redoing the FileURL fields in the db.cfg file - I presently have a trailing slash for that field. Your example places the slash in the output file instead of the db record.

I'll try making a change on the db.cfg file and testing it to see if that corrects the problem. Meanwhile, here's the complete sub html_record_form for your review. You may be able to spot something I've done wrong in this sub.

sub html_record_form {
# --------------------------------------------------------
# The form fields that will be displayed each time a record is
# edited (including searching). You don't want to put the
# <FORM> and </FORM tags, merely the <INPUT> tags for each field.
# The values to be displayed are in %rec and should be incorporated
# into your form. You can use &build_select_field, &build_checkbox_field
# and &build_radio_field to generate the respective input boxes. Text and
# Textarea inputs can be inserted as is. If you turn on form auto
# generation, the program will build the forms for you (all though they may
# not be as nice). See the README for more info.

my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';

print qq|
<TABLE WIDTH="450" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<input type="hidden" NAME="RecordID" VALUE="$rec{'RecordID'}">
<input type="hidden" NAME="FileURL" VALUE="$rec{'FileURL'}">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>ImageName:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="ImageName" SIZE="30" VALUE="$rec{'ImageName'}" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>FileName:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="FileName" SIZE="20" VALUE="$rec{'FileName'}" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>LinkURL:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="LinkURL" SIZE="20" VALUE="$rec{'LinkURL'}" MAXLENGTH="255"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Height:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Height" SIZE="3" VALUE="$rec{'Height'}" MAXLENGTH="3"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Width:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="Width" SIZE="3" VALUE="$rec{'Width'}" MAXLENGTH="3"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>AltText:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="AltText" SIZE="20" VALUE="$rec{'AltText'}" MAXLENGTH="255"></TD></TR>
</TABLE>
|;
}


Thanks again!

------------------
Ogie

We all have challenges in this life, how you deal with them can set you apart!
Quote Reply
Re: linking fileURL? In reply to
Welp...I do not see the problem in the sub html_record_form. I believe that the problem could be the trailing slash that you added in the field definition in the default.cfg file.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: linking fileURL? In reply to
Thanks for looking over the sub Eliot. I tried changing the db.cfg file and that didn't help either. I downloaded the db file and saw that this is added to the FileURL field http://IPADDRESS/FOLDER/~~. I don't know what is causing the additional characters on the end of the entry.

This is the field entry in the cfg file:
FileURL => [2, 'alpha', 80, 250, 1, '', '^http://IPADDRESS/FOLDER/'],

Thanks again for your time and effort, it is much appreciated.

------------------
Ogie

We all have challenges in this life, how you deal with them can set you apart!
Quote Reply
Re: linking fileURL? In reply to
You are confusing database columns...you have the URL in the valid expressions column, when it should be in the default value column.

Change the following codes:

Code:
FileURL => [2, 'alpha', 80, 250, 1, '', '^http://IPADDRESS/FOLDER/'],

to the following:

Code:
FileURL => [2, 'alpha', 80, 250, 1, 'http://IPADDRESS/FOLDER/', ''],

AND you should NOT include the regular expression of starting with. Just include the complete URL in the default value column.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: linking fileURL? In reply to
Hi Eliot, thanks for the effort. I've managed to get the ~~ to change position, but no solution on correcting the problem.
It's now ~~http://IPADDRESS/FOLDER/.

I have used your helpful feedback to correct the field entry
FileURL => [2, 'alpha', 80, 250, 1, 'http://IPADDRESS/FOLDER/', ''],
and tried it both with and without the trailing slash.

In sub html_add_form, I changed the hidden form input field to
<input type="hidden" NAME="FileURL" VALUE="">
to accept the deafult db.cfg entry.

Any other suggestions?

------------------
Ogie

We all have challenges in this life, how you deal with them can set you apart!
Quote Reply
Re: linking fileURL? In reply to
This is your problem:

Code:
<input type="hidden" NAME="FileURL" VALUE="">

Translation: You will get a blank value before the default value, which is causing the double tilda character (~~) to appear.

You have to specify the value of the VALUE attribute with the default value, like the following:

Code:
<input type="hidden" NAME="FileURL" VALUE="$rec{'FileURL'}">

Hope this helps.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: linking fileURL? In reply to
All Right! Found a fix Eliot, thanks for all your help and especially for your patience (it really is appreciated)! Here are the changes made:

In sub html_record - commented out
#$rec{'FileURL'} =~ s/<\/?B>//g;

and used the following (included the slash)
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>FileName:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="$rec{'FileURL'}/$rec{'FileName'}">$rec{'FileURL'}/$rec{'FileName'}</a></TD></TR>
(corrected the missing closing tags, too)

removing the hidden field from sub html_add_form
(guess I tried to do the script's work there :-)

and in db.cfg used (no trailing slash)
FileURL => [2, 'alpha', 80, 250, 1, 'http://IPADDRESS/FOLDER',''],

after cleaning up the sample db and entering a couple more sample records, looks like the complete URL is now being properly displayed.

Thanks again!

------------------
Ogie

We all have challenges in this life, how you deal with them can set you apart!

[This message has been edited by Ogie (edited February 26, 2000).]
Quote Reply
Re: linking fileURL? In reply to
Good...glad you figured out.

Although I have one last suggestion that will reduce disk space (and your database size):

Instead of having a field in your database for the FileURL, simply delete that field from your database and db_def and use the following in your default.cfg or html.pl file:

Code:
$FileURL = "http://www.domain.com/FOLDER";

Then replace the $rec{'FileURL'} with the following:

Code:
$FileURL

Regards,

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited February 26, 2000).]
Quote Reply
Re: linking fileURL? In reply to
 
Quote:
Should I add "my" at the start of each of these entries?

You can use either my or not my variables. All my does is localizes variables and are fixed variables in the script.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: linking fileURL? In reply to
Hi Eliot, sorry for the delay in replying . . . I was distracted with adding some records! This last suggestion could be very helpful in reducing "bulk" in my db. Images also have fixed width/height attributes.

I understand what you've said, I'm not sure how/where to add the definition. I'll give it a shot on how/where I think it might be added, would you please confirm whether I have this correct? (As always, if you have a better solution, your input would be most welcome!)

#Add to GLOBALS at top of html.pl file
$FileURL = "http://www.domain.com/FOLDER";
$ImgHeight = "185";
$ImgWidth = "155";

Should I add "my" at the start of each of these entries?
my $FileURL = "http://www.domain.com/FOLDER";
my $ImgHeight = "185";
my $ImgWidth = "155";

Is "my" a means of identifying user preferences, or does it have another purpose?

Thanks again!

------------------
Ogie

We all have challenges in this life, how you deal with them can set you apart!

[This message has been edited by Ogie (edited February 27, 2000).]