Gossamer Forum
Home : Products : Links 2.0 : Customization :

need to pass affiliate name to add.htm via add.cgi

Quote Reply
need to pass affiliate name to add.htm via add.cgi
Hello Everyone,

I am logging in after a looong time. I need help with a mod/hack.

I would like to setup an affiliate program for people who refer others to my add link form. So, to track I need to parse the affiliate name from the add.cgi. Basically say for affiliate johndoe coming in from add.cgi?affiliate=johndoe, I need to pass the affiliate name (johndoe) to my template, add_html

Anyone has done this? Any ideas?

thanks

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Hello socrates....

What you could do is the following:

1) Add the following codes to the sub main routine:

Code:

elsif ($in{'affiliate'}) {
my $partner = $in{'affiliate'};
&site_html_add_form ($partner);
}


Then in the sub site_html_add_form, you could add the following tag config in the &load_template hash:

Code:

partner => $partner


Then in the add.html template file...add the following:

Code:

<input type="text" name="FieldName" value="<%partner%>">


Hope this helps.

Regards,

Eliot Lee
Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Eliot,

How are you? Thanks a lot, but it does not seem to print the tag in add_html.

I had to reverse the subs below because otherwise it would show the form (add.html) and also on the same page would print add_error.html

Here is my sub main

sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

if ($in{'affiliate'}) {
my $partner = $in{'affiliate'};
&site_html_add_form ($partner);
}

# We are processing the form.
elsif (keys %in != 0) {
&process_form;
}
# Otherwise we are displaying the form (in site_html.pl).
else {
if ($db_single_category) {
my %is_valid = map { $_ => 1 } &category_list;
$ENV{'HTTP_REFERER'} =~ s,/[^/]+\.[^/]+$,,;
$ENV{'HTTP_REFERER'} =~ m,$build_root_url/(.+?)/?$,;
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
}
else {
&site_html_add_form ();
}
}
}




Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
......and did you do what Eliot said in site_html_templates.pl???

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'}"));

print &load_template ('add.html', {
Category => $category,
partner => $partner,
%globals
});
}

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
You did not put the codes in the correct spot....

Replace the following codes:

Code:

else {
if ($db_single_category) {
my %is_valid = map { $_ => 1 } &category_list;
$ENV{'HTTP_REFERER'} =~ s,/[^/]+\.[^/]+$,,;
$ENV{'HTTP_REFERER'} =~ m,$build_root_url/(.+?)/?$,;
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
}
else {
&site_html_add_form ();
}
}


with the following codes:

Code:

else {
if ($db_single_category) {
my %is_valid = map { $_ => 1 } &category_list;
$ENV{'HTTP_REFERER'} =~ s,/[^/]+\.[^/]+$,,;
$ENV{'HTTP_REFERER'} =~ m,$build_root_url/(.+?)/?$,;
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
}
elsif ($in{'affiliate'}) {
my $partner = $in{'affiliate'};
&site_html_add_form ($partner);
}

else {
&site_html_add_form ();
}
}


Then replace the following codes:

Code:

# We are processing the form.
elsif (keys %in != 0) {
&process_form;
}


with the following codes:

Code:

# We are processing the form.
if (keys %in != 0) {
&process_form;
}


Good luck!

Regards,

Eliot Lee
Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Eliot,

Originally, that is where I had put the codes but it returns the add_error.html page for required fields if I put it there (in between). I tried redoing everything per your instructions and it just returns add_error page, this time. I am not sure where the problem is.

Paul - yes, site_html templates was taken care of.

thanks again.

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
You should use the following 'if statement':

Code:
# We are processing the form if there's no affiliate in the input.
if ((keys %in != 0) && (!$in{'ID'})) {
&process_form;
}
Otherwise the script would start processing the form when you call the script like: add.cgi?ID=affiliate

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Ok, I tried several combinations - this is my latest. It prints the add form but does not pass the affiliate name to the template.

sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

# We are processing the form if there's no affiliate in the input.

if ((keys %in != 0) && (!$in{'affiliate'})) {
if ($in{'affiliate'}) {
my $partner = $in{'affiliate'};
&site_html_add_form ($partner);
}
&process_form;
}
# Otherwise we are displaying the form (in site_html.pl).
else {
if ($db_single_category) {
my %is_valid = map { $_ => 1 } &category_list;
$ENV{'HTTP_REFERER'} =~ s,/[^/]+\.[^/]+$,,;
$ENV{'HTTP_REFERER'} =~ m,$build_root_url/(.+?)/?$,;
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
}
else {
&site_html_add_form ();
}
}
}

let me know if you have a solution.

thanks



Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Try this......

sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

# We are processing the form.
if (keys %in != 0) {
&process_form;
}
# Otherwise we are displaying the form (in site_html.pl).
else {
if ($db_single_category) {
my %is_valid = map { $_ => 1 } &category_list;
$ENV{'HTTP_REFERER'} =~ s,/[^/] \.[^/] $,,;
$ENV{'HTTP_REFERER'} =~ m,$build_root_url/(. ?)/?$,;
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
}
else {
if ($in{'affiliate'}) {
my $partner = $in{'affiliate'};
&site_html_add_form ($partner);
} else {
&site_html_add_form ();
}

}
}
}


Then is site_html_templates.pl in site_html_add_form put....

partner => $partner;

Then <%partner%> somewhere in add.html

Should look like this........

sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;

my $category = shift;
my $partner = shift;

$category ?
($category = qq~$category <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));

print &load_template ('add.html', {
Category => $category,
partner => $partner,
%globals
});
}

Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Paul,

Doesn't work. Same thing reported about 3 threads above - just returns add_error.html.

thanks

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Are you passing affiliate into add.cgi properly?

Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Paul, you forgot that the when the script would be called like add.cgi?foo=bar the process_form sub would be triggered at once. That's why you need to use the code:

Code:
sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

# We are processing the form.
if ((keys %in != 0) && (!$in{'affiliate'})) {
&process_form;
}
# Otherwise we are displaying the form (in site_html.pl).
else {
if ($db_single_category) {
my %is_valid = map { $_ => 1 } &category_list;
$ENV{'HTTP_REFERER'} =~ s,/[^/] \.[^/] $,,;
$ENV{'HTTP_REFERER'} =~ m,$build_root_url/(. ?)/?$,;
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
}
else {
&site_html_add_form ();
}
}
}
With site_html.pl you could use put $in{'affiliate'} wherever you would like; but I don't know if
this would work with templates. But I would say: Just try to put <¯filiate%> in your templates. Because it's part of the $in global it should work Wink otherwise use the following code and define $partner in your templates. Only the the category feature will not work in combination with the aflliliate feature.

Code:
sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

# We are processing the form.
if ((keys %in != 0) && (!$in{'affiliate'})) {
&process_form;
}
# Otherwise we are displaying the form (in site_html.pl).
else {
if ($db_single_category) {
my %is_valid = map { $_ => 1 } &category_list;
$ENV{'HTTP_REFERER'} =~ s,/[^/] \.[^/] $,,;
$ENV{'HTTP_REFERER'} =~ m,$build_root_url/(. ?)/?$,;
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
}
else {
if ($in{'affiliate'}) {
my $partner = $in{'affiliate'};
&site_html_add_form ($partner);
} else {
&site_html_add_form ();
}
}
}
}



Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Thats exactly the same code as I gave?......huh?

Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Nope:

if ((keys %in != 0) && (!$in{'affiliate'})) {

Otherwise add.gi will start processing eth form directly with add.cgi?affiliate=chrishintz and that's the reason of the error message.

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
O I C what you mean now Smile

Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Hello Folks,

Is this a hard nut to crack? I could not get it to work.

Regards

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
In Reply To:
I could not get it to work.
That's not a really specific problem!
If you complain that it's not working you should alsow tell the type of error you get; al least!

But because I posted a code that works with site_html.pl for sure it should alsow work with templates after you defining some vars.

So maybe you can post your add.cgi and (a part of your) templates_html.pl as txt file online. Then we will have a look. It should be simple Wink

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Dude,

I appreciate your helping me. I have already posted everything in my posts above - very specific, including the problems and codes.

It's just not working. I just wanted to report that. I do not see a point in posting the same thing agian and again, that I have already posted two or three posts above. I have also tried your solution that you posted, but it did not work. I know it should be simple - that's what I thought. But it ain't, so far.

thanks

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Sorry, then I (and I alsow think others) can't help you!

Because I you used the EXACT same code I wrote last time, and adjusted it correct to the templates version it MUST work. I have a simular add.cgi myself; but instead of affiliate in have ID.

You can't expect that we (other users) will write the code snippets, put everything together and run tests.
We already give the snippets you need, now you just need to put evrything together run some test and come up with SPECIFIC errors aor bugs.


Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Ok, I am sorry - I am an idiot!
Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
I have something useful to say...... a simple philosophy in life that I believe:

Those that ask for help, must also help themselves. Otherwise it's no longer help....it's a free ride.

Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
In Reply To:
I need help with a mod/hack. ....Anyone has done this? Any ideas?
Next time you should write:

I want somebody to write a mod for me! You'll need to be sure it will work on my links version. I won't give you feedback. Just do it!

Note: I used the instructions of chrishintz and everything works fine for me! So what's your problem?!


Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
In Reply To:
I have already posted everything in my posts above - very specific, including the problems and codes.
.....if you read the above threads (and noticed when testing) that code won't work. Therefore I asked you to post you latest code; with all tips and codehelp implemented.

But don't worry, I won't bother you anymore!

Note: I'm really enjoying my affiliate programm Wink


Quote Reply
Re: need to pass affiliate name to add.htm via add.cgi In reply to
Chrishintz,

Sorry, I am an idiot. Thank you and thanks to all of you for helping me (now and in the past).