Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Sending Unknown TAG "AltCategories" email to user if user doesn't select AltCategory

Quote Reply
Sending Unknown TAG "AltCategories" email to user if user doesn't select AltCategory
I am truelly frustrated with this one, I've searched unseccessfully for the cause everywhere. Two Problems:
1 - The problem is I am getting a POPUP message from my browser saying RUNTIME ERROR LINE 413 when user trying to add his site to the directory without speciffing an Altgategory. If I look at line 413 it has <% AltCategories %>.

2 - If user does not select any altcategory, then he/she will receive an email saying UNKNOWN TAG "AltCategories" when I validate his/her entry. However, the user will receive the right email with Category and Altecategory specified in it if he/she selected an altcategory when adding his/her site into the direcotory.
Could you please help me in finding where is the problem. here is my code:

in add.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'}
Country Categories: $in{'AltCategories'}
Description: $in{'Description'}
Contact Name: $in{'Contact Name'}
Contact Email: $in{'Contact Email'}

Remote Host: $ENV{'REMOTE_HOST'}
Referer: $ENV{'HTTP_REFERER'}

To validate, please go to:
$db_script_url

Sincerely,

Links Manager.
|;

================================================================
in db_utils.pl
---------------

sub build_select_field {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $mult) = @_;
my ($size, %values, $field_clean);

$name | | ($name = $column);
$size | | ($size = 1);

if (! exists $db_select_fields{$column}) {
$db_select_fields{$db_cols[$db_category]} = $db_select_fields{'Mult-Related'} = join (",", &category_list);
}
# added the following 4 lines from: http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/000960.html for altcategory.
# also modified them to look like: http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/004672.html

if (! exists $db_select_fields{$column} && $column eq "AltCategories" && exists $db_select_fields{'Category'}) {
$db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = $db_select_fields{'Category'}}
elsif (! exists $db_select_fields{$column} && $column eq "AltCategories" && ! exists $db_select_fields{'Category'}) {
$db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = join (",", &category_list);}


if ($mult) {
@fields = split (/\,/, $db_select_fields{"Mult-$column"});
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
@fields = split (/\,/, $db_select_fields{$column});
$values{$value}++;
}
($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";

$output = qq|<SELECT NAME="$name" $mult SIZE=$size><OPTION>---|;
foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
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));
($db_select_fields{$db_cols[$db_alt]} = $db_select_fields{'Mult-AltCategories'} = 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, "SELECT SIZE=1") . "</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~; }
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~; }
}
$output .= "</table></p>\n";
return $output;
}

==============================================================
In Site_html_templates.pl:
--------------------------

# MARK - chnaged the procedures below to add multicategory from loopy:
# at: http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/000960.html
########################################################################################
# THE FOLLOWING ARE CGI GENERATED PAGES AND THE TEMPLATE MUST BE PRINTED, NOT RETURNED!#
########################################################################################
sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;
my $category = shift;
# $category ?
# ($category = qq~$category <input type=hidden name="Category" value="$category">~) :
# ($category = &build_select_field ("Category", "$in{'Category'}"));
my $category = &build_select_field ("Category", "$category");
my $altcategories = &build_select_field ("AltCategories","$in{'AltCategories'}","AltCategories","SELECT Size=1");

print &load_template ('add.html', {
AltCategories => $altcategories,
Category => $category,
%globals
});
}
sub site_html_add_success {
# --------------------------------------------------------
# This routine determines how the add success page will look like.
&html_print_headers;
print &load_template ('add_success.html', {
AltCategories => $altcategories,
%in,
%globals
});
}
sub site_html_add_failure {
# --------------------------------------------------------
# This routine determines how the add failure page will look like.
my ($errormsg) = shift;
my $category = &build_select_field ("Category", "$in{'Category'}");
delete $in{'Category'};
my $altcategories = &build_select_field ("AltCategories","$in{'AltCategories'}","AltCategories","SELECT Size=1");
delete $in{'AltCategories'};

&html_print_headers;
print &load_template ('add_error.html', {
AltCategories => $altcategories,
Category => $category,
error => $errormsg,
%in,
%globals
});
}
sub site_html_modify_form {
# --------------------------------------------------------
# This routine determines how the modify form page will look like.
my $category = &build_select_field ("Category", "$in{'Category'}");
my $altcategories = &build_select_field ("AltCategories","$in{'AltCategories'}","AltCategories","SELECT Size=1");
&html_print_headers;
print &load_template ('modify.html', {
AltCategories => $altcategories,
Category => $category,
%globals
});
}
sub site_html_modify_success {
# --------------------------------------------------------
# This routine determines how the modify success page will look like.
&html_print_headers;
print &load_template ('modify_success.html', {
AltCategories => $altcategories,
%in,
%globals
});
}
sub site_html_modify_failure {
# --------------------------------------------------------
# This routine determines how the modify failure page will look like.
my $errormsg = shift;
my $category = &build_select_field ("Category", "$in{'Category'}");
delete $in{'Category'};
# $in{'Category'} = &build_select_field ("Category", $in{'Category'});
my $altcategories = &build_select_field ("AltCategories","$in{'AltCategories'}","AltCategories","SELECT Size=1");
delete $in{'AltCategories'};
&html_print_headers;
print &load_template ('modify_error.html', {
AltCategories => $altcategories,
Category => $category,
error => $errormsg,
%in,
%globals
});
}

================================================================

In email-add.txt:
-----------------
Title : <%Title%>

URL : <%URL%>

Main Category : <%Category%>

Country Category: <%AltCategories%>

Description : <%Description%>

Contact Name : <%Contact Name%>

Contact Email : <%Contact Email%>

=================================================================

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, '', ''],
AltCategories => [5, 'alpha', 0, 500, 0, '', ''],
Description => [6, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [7, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [8, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [9, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [10, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [11, 'alpha', 0, 5, 0, 'No', ''],
Rating => [12, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [13, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [14, 'alpha', 10, 10, 1, 'Yes', 'No|Yes']
);

# 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_alt = 5;
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 9; $db_isnew = 10; $db_ispop = 11;
$db_contact_name = 7; $db_contact_email = 8; $db_title = 1;
$db_votes = 13; $db_rating = 12; $db_mail = 14;

=============================================================



================================================================

and in the nph-build.cgi I have the changes of loopy as specified in Loopy Multi-category:
http://www.online-sweepstakes.com/links-mods/

Could you please tell me where could be the error generating from and where I can declare the AltCategory..
I am really having a hard time with this script eventhough it adds the suggusted link to the suggusted category and altecategory. But if the AltCategory was left blank when the user is filling out the form, he will get The unknown tag AltCategories in his email after I validate the suggusted link..

Thank you in advance for your help..
Regards..
Mark..


[This message has been edited by Edmk (edited February 10, 2000).]
Quote Reply
Re: Sending Unknown TAG "AltCategories" email to user if user doesn't select AltCategory In reply to
You seem to be confusing tags.

Code:
If I look at line 413 it has <% AlCategories %>.

It should be:

Code:
<%AltCategories%>

You are missing the t.

Regards,


------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------








Quote Reply
Re: Sending Unknown TAG "AltCategories" email to user if user doesn't select AltCategory In reply to
Eliot,
I missed spelled it in my thread only. It is spelled correctly in the add.html / add.cgi.

Thanks..
Mark
Quote Reply
Re: Sending Unknown TAG "AltCategories" email to user if user doesn't select AltCategory In reply to
May be this Thread will help you:

http://www.gossamer-threads.com/...um3/HTML/004672.html

This issue has been raised several times in the Modification Forum...try searching it if this Thread does not help you.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------








Quote Reply
Re: Sending Unknown TAG "AltCategories" email to user if user doesn't select AltCategory In reply to
It really froze my work since 10 days and still waiting on a solution!!. Can Anyone help in this one..
(how will you make the altcategory field in the add form an optional field without sending UNKNOWN TAG ALTCATEGORY in the email to the user after you validated the link.
Also, Modify a link is not sending email after the validation. Add does.

Thank you in advance..
Mark..
Quote Reply
Re: Sending Unknown TAG "AltCategories" email to user if user doesn't select AltCategory In reply to
Hi Eliot,
I have already implemented the thread that you suggusted, but unfortunitely it did not work. I, almost, searched everywhere in the forum for a solution without any luck, I was wonder if Elem would know anything about this one.
Anyway thank you Eliot for your help...