Like so, in links.def:
# Database Definition: LINKS
# --------------------------------------------------------
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '',
'.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes']
, isNSF => [14, 'alpha', 0, 5, 0, 'No', ''], NSFnum => [15, 'alpha', 40, 75, 0, '', ''] );
# Database file to use -- defined in links.cfg.
$db_file_name = $db_links_name;
# Counter file to use -- defined in links.cfg.
$db_id_file_name = $db_links_id_file_name;
# The column name for the database key.
$db_key = 'ID';
# Database delimeter.
$db_delim = '|';
# Title used in admin output.
$html_title = 'Links Database';
$html_object = 'Link';
# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_isNSF = 14; $db_NSFnum = 15; # Field number to sort links by:
$db_sort_links = 1;
# Field names you want to allow visitors to search on:
@search_fields = (1,2,5);
# System defaults. When adding new links or modifying links, these fields
# can not be overwritten by a user.
%add_system_fields = (
isNew => 'No',
isPopular => 'No',
Hits => '0',
Rating => 0,
Votes => 0,
ReceiveMail => 'Yes'
);
# Hash of column names to possible options. If you want to use a select form
# field, you can use &build_select_field in your HTML page. This routine will
# make a <SELECT> input tag using the following values:
%db_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No',
ReceiveMail => 'Yes,No'
, isNSF => 'Yes,No'
);
-------
Then in your link.html template:
<ul><li><a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>
<%if Description%>
<span class="descript">- <%Description%></span>
<%endif%>
<%if isNSF%>
<span class="descript">This person is funded by the NSF, and their grant number is <%NSFnum%></span>
<%endif%> <%if isNew%>
<small><sup class="new">new</sup></small>
<%endif%>
<%if isPopular%>
<small><sup class="pop">pop</sup></small>
<%endif%>
<small class="date">(Added: <%Date%> Hits: <%Hits%> Rating: <%Rating%> Votes: <%Votes%>) <a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It</a></small>
</ul>
----
Then in add.html:
<table border ="0" cellspacing="0" cellpadding="0">
<tr><td align="right" valign="top">Title:</td>
<td><input name="Title" size="50"></td></tr>
<tr><td align="right" valign="top">URL:</td>
<td><input name="URL" size="50"></td></tr>
<tr><td align="right" valign="top">Category:</td>
<td><%Category%></td></tr>
<tr><td align="right" valign="top">Description:</td>
<td><textarea wrap="virtual" name="Description" value="" rows="3" cols="42"></textarea></td></tr>
<tr><td align="right" valign="top">Contact Name:</td>
<td><input name="Contact Name" value="" size="40"></td></tr>
<tr><td align="right" valign="top">Contact Email:</td>
<td><input name="Contact Email" value="" size="40"></td></tr>
<tr><td align="right" valign="top">NSF?:</td>
<td><select class="form" name="isNSF" size=1><option>---<OPTION SELECTED VALUE="No">No
<OPTION VALUE="Yes">Yes</select> </td></tr> <tr><td align="right" valign="top">NSF Number:</td>
<td><input name="NSFnum" value="" size="40"></td></tr> <tr><td></td><td><input type="SUBMIT" value="Add Resource"></td></tr>
</table>
----
The other changes to add_error, add_success, modify, modify_error and modify_success should be easy to figure out. Also make changes in add.cgi and modify.cgi:
sub send_email {
# --------------------------------------------------------
# Sends an email to the admin, letting him know that there is
# a new link waiting to be validated. No error checking as we don't
# want users to see the informative &cgierr output.
# Check to make sure that there is an admin email address defined.
$db_admin_email or &cgierr("Admin Email Address Not Defined in config file!");
my $to = $db_admin_email;
my $from = $in{$db_cols[$db_contact_email]};
my $subject = "Addition to Database: $in{'Title'}\n";
my $msg = qq|
The following link is awaiting validation:
Title: $in{'Title'}
URL: $in{'URL'}
Category: $in{'Category'}
Description: $in{'Description'}
Contact Name: $in{'Contact Name'}
Contact Email: $in{'Contact Email'}
NSF Number: $in{NSFnum} Remote Host: $ENV{'REMOTE_HOST'}
Referer: $ENV{'HTTP_REFERER'}
To validate, please go to:
$db_script_url
Sincerely,
Links Manager.
|;
----
Actually, the
isNSF codes are not necessary, unless you have a specific need for it. Just change the link.html to this:
<%if NSFnum%>
<span class="descript">This person is funded by the NSF, and their grant number is <%NSFnum%></span>
<%endif%> This will show the text only if there is an entry in the NSFnum field, otherwise it will be skipped. ----
I'm not sure what you want with this:
Quote:
2. simplify the "categories" option on the "add a link" page.
there will be many many categories to add links to, and i was curious if anyone knows how to make a giant list simpler in Linksv2.
Any questions, fire away!
Leonard
aka PerlFlunkie