Gossamer Forum
Home : Products : Links 2.0 : Customization :

adding new fields - prob with links.def

Quote Reply
adding new fields - prob with links.def
Hello *,

yes I read ll the faq's of the ressource center and the posts of this forum to "add new fields" to my links.db
e.g. http://gossamer-threads.com/perl/forum/showflat.pl?ubb=000865:Forum3

But I cannot solve a problem with my links.def. Everytime I want to run admin.cgi I get the fatal error:
In Reply To:
links.def did not return a true value at admin.cgi line 55
Any kind of ideas? It would be very kind of you, if you could help me!

I post my links.def here ->
Code:
# 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', '\:\/\/'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '50x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
PLZ => [8, 'numer', 5, 8, 0, '', ''],
Ort => [9, 'alpha', 40, 75, 0, '', ''],
Land => [10, 'alpha', 5, 8, 0, '', ''],
Region => [11, 'alpha', 40, 40, 0, '', ''],
Hits => [12, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [13, 'alpha', 0, 5, 0, 'Yes', ''],
isPopular => [14, 'alpha', 0, 5, 0, 'No', ''],
Rating => [15, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [16, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [17, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
DateAdded => [18, 'date', 15, 15, 0, \&get_date, '']
);

# 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 = 'Juhu!Katzen! Datenbank';
$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_plz = 8; $db_ort = 9; $db_land = 10; $db_region = 11;
$db_hits = 12; $db_isnew = 13; $db_ispop = 14;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 16; $db_rating = 15; $db_mail = 17;
$db_dateadded = 18;


# Field number to sort links by:
$db_sort_links = 1;

# Field names you want to allow visitors to search on:
@search_fields = (1,2,4,5,6);

# System defaults. When adding new links or modifying links, these fields
# can not be overwritten by a user.
%add_system_fields = (
isNew => 'Yes',
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'
);

# Hash of column names to radio values. If you use &build_radio_field, it will
# make a <INPUT TYPE="RADIO"> tag for you using the options specified in the hash.
%db_radio_fields = ( );

# Maximum number of hits returned in a search. Can be overridden in the search
# options.
$db_max_hits = 10;

# Use the built in key tracker.
$db_key_track = 1;

# ===========================================================================
# Build up some variables from your definitions. Internal use only.
@db_cols = ();
foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) {
push (@db_cols, $_);
$db_sort{$_} = $db_def{$_}[1];
$db_form_len{$_} = $db_def{$_}[2];
$db_lengths{$_} = $db_def{$_}[3];
$db_not_null{$_} = $db_def{$_}[4];
$db_defaults{$_} = $db_def{$_}[5];
$db_valid_types{$_} = $db_def{$_}[6];
($_ eq $db_key) and $db_key_pos = $db_def{$_}[0];
}

1;
Thanks a lot for answering me ;-)

CU
Groeni


Quote Reply
Re: adding new fields - prob with links.def In reply to
Hmm links.def looks ok.

Did you edit anything else?

Just out of interest why do you need "DateAdded" when "Date" already contains that value.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: adding new fields - prob with links.def In reply to
Hey Paul,

no, I didn't edit anything else - that's why I'm in dispair! :-(
Shall I post my admin.cgi? Will that helpful?

BTW: DateAdded is the date where the link was first added, Date is the date of the last modification. See more at the mod-center ;-)

Best wishes
Groeni

Quote Reply
Re: adding new fields - prob with links.def In reply to
Have you tried removing the fields you added to see if it starts to work again?


Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: adding new fields - prob with links.def In reply to
Yes! No problems anymore!

sigh :-(

Quote Reply
Re: adding new fields - prob with links.def In reply to
Could you post exactly what you removed so we can narrow it down.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: adding new fields - prob with links.def In reply to
Sure!

Code:
# 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', '\:\/\/'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '50x3', 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, 'Yes', ''],
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'],
DateAdded => [14, 'date', 15, 15, 0, \&get_date, '']
);

# 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 = 'Juhu!Katzen! Datenbank';
$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_dateadded = 14;


# Field number to sort links by:
$db_sort_links = 1;

# Field names you want to allow visitors to search on:
@search_fields = (1,2,4,5,6);

# System defaults. When adding new links or modifying links, these fields
# can not be overwritten by a user.
%add_system_fields = (
isNew => 'Yes',
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'
);

# Hash of column names to radio values. If you use &build_radio_field, it will
# make a <INPUT TYPE="RADIO"> tag for you using the options specified in the hash.
%db_radio_fields = ( );

# Maximum number of hits returned in a search. Can be overridden in the search
# options.
$db_max_hits = 10;

# Use the built in key tracker.
$db_key_track = 1;

# ===========================================================================
# Build up some variables from your definitions. Internal use only.
@db_cols = ();
foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) {
push (@db_cols, $_);
$db_sort{$_} = $db_def{$_}[1];
$db_form_len{$_} = $db_def{$_}[2];
$db_lengths{$_} = $db_def{$_}[3];
$db_not_null{$_} = $db_def{$_}[4];
$db_defaults{$_} = $db_def{$_}[5];
$db_valid_types{$_} = $db_def{$_}[6];
($_ eq $db_key) and $db_key_pos = $db_def{$_}[0];
}

1;
This one works!
Can you see the difference that causes the prob?

CU
Groeni

Quote Reply
Re: adding new fields - prob with links.def In reply to
Thanks a lot! I did it! Don't know why the first time it doesn't work, cos I change anything but write it again. Now it works! Maybe a escape-letter or something like this!

Best wishes
Groeni