Gossamer Forum
Home : Products : Links 2.0 : Customization :

New admin URL-view mod

Quote Reply
New admin URL-view mod
Tired of always having to copy and paste URLs when modifying/viewing links from the admin interface? Try this mod to make links active:

In db_utils.pl

CHANGE (under build_html_record):

Code:
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;

TO:

Code:

if ($field eq "URL" && $rec{$field} ne "") {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>
~;
}
else {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
}

CHANGE (under build_html_record_form):

Quote:
else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }

TO:

Quote:
else {
if ($field eq "URL" && $rec{$field} ne "") {
$output .= qq~<tr><td align=right valign=top width=20%><$font><a href="$rec{$field}" target="_blank">$field</a>:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~;
}
else {
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
}

That's all!

(Did you know why you go to edit, the code segments disappear?)

Owen

[This message has been edited by Owen (edited April 08, 2000).]
Quote Reply
Re: New admin URL-view mod In reply to
I think you are missing a bracket on the second change. Should there be a close bracket at the end of this line?
Code:
{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~;

------------------
Jimmy Crow
www.homewithgod.com
Quote Reply
Re: New admin URL-view mod In reply to
Oops. Thanks. I updated the code above.

Owen
Quote Reply
Re: New admin URL-view mod In reply to
That's a handy little time saver. Never would have thought about one. I've been adding and modifying links today and had to cut and paste.

Thanks!

------------------
Jimmy Crow
www.homewithgod.com

[This message has been edited by jcrow (edited April 08, 2000).]

[This message has been edited by jcrow (edited April 08, 2000).]
Quote Reply
Re: New admin URL-view mod In reply to
Update: If you don't want a non-existant URL to be highlighted on the add-URL page, you can change (in the second code segment):

from:
Code:
if ($field eq "URL" && $rec{$field} ne "") {

to:
Code:
if ($field eq "URL" && $rec{$field} ne "" && $rec{$field} ne "http://") {

It's not too important, though.

Owen
Quote Reply
Re: New admin URL-view mod In reply to
sorry wrong post & thread...




[This message has been edited by Ugur (edited April 11, 2000).]
Quote Reply
Re: New admin URL-view mod In reply to
could you email me the db_utils.pl file I keep messing up the editing on this mod?

Quote Reply
Re: New admin URL-view mod In reply to
Thanks for this quick, but very useful, mod. Much appreciated!

Simon Dyson

Quote Reply
Re: New admin URL-view mod In reply to
Hi,

I've tried several times to get this mod to work but I keep getting Synax errors, can't find the missing fragment causing the problem. Can you please mail the db_utils.pl to me so I can look it over or replace mine with it?

Thank yo13532C
Doug

Quote Reply
Re: [Owen] New admin URL-view mod In reply to
Im having a hard time finding my problem here... I dont know what I missed, but I have a little error message:

Quote:
Error including libraries: Missing right bracket at .../cgi-bin/admin/db_utils.pl line 636, at end of line
syntax error at .../admin/db_utils.pl line 636, at EOF

Make sure they exist, permissions are set properly, and paths are set correctly.
Quote Reply
Re: [jbridge14] New admin URL-view mod In reply to
As the error message indicates: your are missing a right bracket at line 636 in db_utils.pl.
Quote Reply
Re: [Owen] New admin URL-view mod In reply to
hmm .. kinda strange admin :)

Code:
Check which record you wish to modify and then press "Modify ":
Your search returned 1013 matches.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... [>>]

ID: 50


ID: 70


ID: 85


ID: 86


ID: 97


ID: 102


ID: 145


ID: 157


ID: 173


ID: 220



Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... [>>]

any idea what happened

Gregor
Quote Reply
Please Help Me With This MOD In reply to
Hi All,

I have tried several times to get this mod to work but like some others I get the error As the error message indicates: your are missing a right bracket at line 636 in db_utils.pl PLEASE email me all the files needed to make this work. You can't send them to my business email because it blocks file attachments please send the files allready edited and working to this email doug72261@yahoo.com

I really need this mode for my Links program. Any help would be very much appreciated.

Doug
Quote Reply
Re: [Technel] Please Help Me With This MOD In reply to
Another thread dug up from the dusty past... Unimpressed

When you have a problem like this, go through your code (either on screen or printed), and put a letter by each curly bracket, and make sure they match open- and close-wise, and maybe put notes in for the closing ones. Ignore the smaller ones, like "$rec{$field}", since it's obvious that both brackets are there.

Example:

sub build_html_record { #A
# --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);

$output = "<p><table border=1 width=450>\n";
foreach $field (@db_cols) { #B
next if ($db_form_len{$field} == -1);
# >>> Admin URL View mod
if ($field eq "URL" && $rec{$field} ne "") { #C
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>~;
} #/C
else { #D

$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
} #/D
# >>> Original code:
# $output .= qq~
# <tr><td align=right valign=top width=20%><$font>$field:</font></td>
# <td width=80%><$font>$rec{$field}</font></td></tr>
# ~;
# <<< Admin URL View mod
} #/B ends 'foreach'
$output .= "</table></p>\n";
return $output;
} #/A



Here are the subs with the code added for this mod, you can just paste these in if you have not made any other changes to your files:
Code:
sub build_html_record {
# --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);

$output = "<p><table border=1 width=450>\n";
foreach $field (@db_cols) {
next if ($db_form_len{$field} == -1);
# >>> Admin URL View mod
if ($field eq "URL" && $rec{$field} ne "") {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>~;
}
else {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
}
# >>> Original code:
# $output .= qq~
# <tr><td align=right valign=top width=20%><$font>$field:</font></td>
# <td width=80%><$font>$rec{$field}</font></td></tr>
# ~;
# <<< Admin URL View mod
}
$output .= "</table></p>\n";
return $output;
}sub build_html_record_form {
# --------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_; $output = "<p><table border=1>";# Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
} foreach $field (@db_cols) {
# Set the field name to field-key if we are doing multiple forms.
$multiple ? ($name = "$field-$rec{$db_key}") : ($name = $field);
if ($db_select_fields{"Mult-$field"}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name, "MULTIPLE SIZE=3") . "</td></tr>\n"; }
elsif ($db_select_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_radio_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_form_len{$field} =~
/(\d+)x(\d+)/) { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea wrap="virtual" name="$name" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>\n~; }
elsif ($db_form_len{$field} == -1) { $output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }
# >>> Admin URL View mod
else {
if ($field eq "URL" && $rec{$field} ne "") { $output .= qq~<tr><td align=right valign=top width=20%><$font><a href="$rec{$field}" target="_blank">$field</a>:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
}
# >>> Original code:
# else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
# <<< Admin URL View mod
} # ends 'foreach'
$output .= "</table></p>\n";
return $output;
}


Leonard
aka PerlFlunkie