Gossamer Forum
Home : Products : Links 2.0 : Customization :

Is this possible w/ AddURL?

Quote Reply
Is this possible w/ AddURL?
Hey all --

I have a client who wants to add SEVERAL fields to the
AddURL form, but does not want the fields written to the database. Let me illustrate:

Say fields 1 - 10 represent the standard fields in the AddURL form. The ones that we aaaaaaall have. Now fields 11 - 20 are the ones the client wants to add.

Once the user has filled out ALL 20 fields and clicks submit, the data entered into all 20 fields gets emailed to my client BUT only the data in fields 1 - 10 gets entered into the database.

Does this make sense, and can it be done?

Thanks tons!

Cynthia
Quote Reply
Easy.... In reply to
Its just a matter of seven steps.

1) Edit the links.def file to have more records in stead of the standard 13. (search for more info.)

Code:
New_Field => [9, 'alpha', 0, 5, 0, 'No', ''],

2) Add the following to links.def (To override the entered values of records 14-20)

Code:
# Extra defaults. When adding new links or modifying links, these fields
# can not be overwritten by a user.
%no_initial_value = (
New_Field => '',
New_Field_2 => 'Or some default value'
);

3) Add the following to add.cgi (in the sub_process_form; at the top.)

Code:
sub process_form {
# --------------------------------------------------------
local (%org);

4) Add the following to add.cgi (just under # Check the referer.)

Code:
# This will set the field 14-20 to the proper value and assign all orginal value to $org{'New_Field'}
foreach $key (keys %no_initial_value) {
$org{$key} = $in{$key}; # set value to $org{}
$in{$key} = $no_initial_value{$key}; #override value in $in{} ($in{} = database)
}

5) Modify the add.html template (and the error and success one).

6) Edit the following sub routine is add.cgi

Code:
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{'ID'}\n";
my $msg = qq|

### INSERT TEXT OF EMAIL ###
### Use $in{'Field_name 1-13'} and $org{'Fieldname 14-20'} ###
### have a look at modify.cgi for more info ###
### INSERT TEXT OF EMAIL ###

|;

# Then mail it away!
require "$db_lib_path/Mailer.pm";
my $mailer = new Mailer ( { smtp => $db_smtp_server,
sendmail => $db_mail_path,
from => $from,
subject => $subject,
to => $to,
msg => $msg,
log => $db_mailer_log
} ) or return;
$mailer->send or return;
}

That's it.

NOTE: No garantee, I just typed something Wink

Last edited by:

cK: Jun 15, 2002, 12:14 AM
Quote Reply
Re: [WKDesign] Is this possible w/ AddURL? In reply to
Or you could cut out a lot of those steps and simply edit your template files to include those files for the client, then edit the SEND EMAIL routine in the add.cgi script.

Of course, the benefit of the codes that CK offered is that you can set certain "constraints" on the fields, but if all you want to do is allow the client to add info and have it emailed to him or her, all you have to do is edit the template files and then the email sub in the add.cgi script.

Seems odd though that this one client wants to "add" stuff into a form (10+ fields) and only have it emailed to him/or her. Seems like a big hassle to modify your business rules for one client.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [WKDesign] Is this possible w/ AddURL? In reply to
Have you tried setting up 2 add URL templates. One for "Standard/Normal" and the other as "Extended/More Options"? Then create a page so the client could choose which form they want to fill out, Standard or Extended with an explanation of each.

In theory it would be the same as I have created on my site for adding/updating URLs. I have set two levels of security. First you must "sign up" to enter the add/update area (this makes a person feel like they belong to or is a part of the organization) then I used Pauls ModifyProtection mod for additional security so that only the person that added the URL can modify it.

Check it out http://surelinksalot.com/directory/ add your URL. Then let me know if you came across any issues. I am still working out some minor problems. I also always appreciate suggestions.

If you need help with this contact me via e-mail. (see my profile)

Web Rat
Davez Webz
Sure Links A Lot
Quote Reply
Re: [Stealth] Is this possible w/ AddURL? In reply to
Quote:
Or you could cut out a lot of those steps and simply edit your template files to include those files for the client, then edit the SEND EMAIL routine in the add.cgi script.

Stupid, I didn't think of that! Frown

Offcourse, all extra variables are submitted to add.cgi, but not to the database. So I would be very handy to use them in the email. I didn't think of that because I first wrote the code to save all variables, and the editted when I saw this was not was WKDesign wanted........