Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Sub handling in add.pm

Quote Reply
Sub handling in add.pm
I've nearly lost it at this point...I've been trying to get Links to use a multipart form for months now with no success. I've tried following the suggestions given by Andy and Paul, (btw...thanks guys!), but I'm obviously not as well versed in Perl unfortunately. I've been hacking away at the add.pm file and I've gotten it to accept page 1 and store the values, then go on to page two...problem is, page one is viewable by scrolling down. It shows both pages at the same time!!! I've been looking through my books, but can't figure out how to stop this from happening.

Could someone please give me a hand with this....it is Christmas Unsure

Code:
sub handle {
# -------------------------------------------------------------------
# Display either an add form or process an add request.
#
if ($CFG->{user_required} and ! $USER) {
print $IN->redirect( Links::redirect_login_url ('add') );
return;
}
# We are processing an add request.
if ($IN->param('pg1')) {
my $results = GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'user_add_link', \&add_link, {});
print $IN->header();
print Links::SiteHTML::display ('pg2');
}

if ($IN->param('pg2')) {
my $results = GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'user_add_link', \&add_link, {});
print $IN->header();
print Links::SiteHTML::display ('pg3');
}

if ($IN->param('pg3')) {
my $results = GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'user_add_link', \&add_link, {});
print $IN->header();
print Links::SiteHTML::display ('pg4');
}
else {
print $IN->header();
print Links::SiteHTML::display ('add_success', $results);
}
}

Perl Hopefull
Quote Reply
Re: [stilton] Sub handling in add.pm In reply to
Try adding

return;

statements after the print Links::SiteHTML::display lines. And you probably only want to add the 'my $results = ...' line in the case where 'pg3' is true.

You could also substitute your various 'if' clauses by an

if () {
}
elsif () {
}
elsif () {
}
else {
}

clause. I that case you don't need the returns.

I hope that helps.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Sub handling in add.pm In reply to
Hi Ivan,

That helped tremendously! I was extremely pleased to see the double windows disappear from the screen and revert back to normal. The only odd behavior I see now, is that when it submits to the database, it actually submits the link twice now....not exactly sure why. I'm going to play with it some more...your input is greatly appreciated and I'll take any other suggestions you can think of.

Steve
Perl Hopefull
Quote Reply
Re: [stilton] Sub handling in add.pm In reply to
Quote:
he only odd behavior I see now, is that when it submits to the database, it actually submits the link twice now....not exactly sure why.[/qoute]
As I said, you need to take out the various occurences of 'my $return = ....', so that this line is only present after the user submitted page three (i.e. when 'pg3' is true).

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [stilton] Sub handling in add.pm In reply to
I realize this is pretty old... but it came up on an unrelated search.

There are ways to do a multi part submission form.
Our postcards plugin does this, and it has to do with a simple "passvar" tag.
I think there were several other threads on getting add / add.cgi to handle multi page forms as well

As long as you don't want to process any input until the final submit, there are several ways to do it.

Just tagging an old thread in case there are people still struggling with trying to do something like this.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.