Gossamer Forum
Home : Products : Links 2.0 : Customization :

add confirm routine to sort field by name

Quote Reply
add confirm routine to sort field by name
Hello,

There is an add_confirm routine to let users confirm the form inputs before they submit it. I have some extra fields added in my links.def. When someone adds a link and goes to the add confirm page, the fields are all over the place - they are neither listed alphabetically nor listed based on the links.def filed numbers nor listed by the addform values in the way input form is configured.

Is there a way to sort the fields before they are printed in the add_confirm.html page (prefarably based on the way add form is setup and the way user fills in the form).

Thanks,

sub site_html_confirm_add {
# --------------------------------------------------------
&html_print_headers;
my $num = 0;
foreach $var (%in){
$num++;
}
$formvals .=qq|<form action= "add.cgi" method="POST">|;
for ($i = 0; $i < ($num/2); $i++) {
(($name, $value) = each %in);
$details .=qq|<b>$name:</b> <font color="#ff0000">$value</font><br>|;
$formvals .=qq|<input type="hidden" name="$name" value="$value">|;
}
print &load_template ('add_confirm.html', {
details => $details,
formvals => $formvals,
%in,
%globals
});
}
Quote Reply
Re: [socrates] add confirm routine to sort field by name In reply to
Looks like that mod is using cgi.pm, which I have not played with too much. Try something like this, where in place of this:

for ($i = 0; $i < ($num/2); $i++) {
(($name, $value) = each %in);
$details .=qq|<b>$name:</b> <font color="#ff0000">$value</font><br>|;
$formvals .=qq|<input type="hidden" name="$name" value="$value">|;
}


(Substitute the names with your field names, keeping case-sensitivity in mind.)

$name = param("name");
$title = param("title");

Then on your template use the variable names where you want:

Name: $name<br>
Title: title<br>

No guarantees on that! It would help if you let us see your add_confirm.html code, and/or a link to where you found the mod.

There are other ways to do this same thing, that do not use cgi.pm...

http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=286065#286065


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] add confirm routine to sort field by name In reply to
Thanks but it is not clear to me what you mean by the following - can you explain further?
Code:

(Substitute the names with your field names, keeping case-sensitivity in mind.)

$name = param("name");
$title = param("title");

Then on your template use the variable names where you want:

Name: $name<br>
Title: title<br>


Do I need to list all of my fields from links.def in there?
Quote Reply
Re: [socrates] add confirm routine to sort field by name In reply to
Yes, you would need to list each one. Do a test one first, to make sure it will work, before adding them all. Also, I left off a dollar sign:

Name: $name<br>
Title: $title<br>



Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] add confirm routine to sort field by name In reply to
I tried that and it didn't work (I also tried your cgi.pm and for some reason didn't seem to send filed values to the add_confirm page and took a long time to process the data) but here is a simpler solution:

1) In my first sub above just comment these two lines -
#$details .=qq|<b>$name:</b> <font color="#ff0000">$value</font><br>|;
and
#details => $details,

2) In the add_confirm.html templates:

Just leave <%filedvalues%> and remove<%details%>

and then list your fields in the order you want, like so:

Title - <%Title%><br>
Contact Name - <%Contact Name%><br>
Contact Email - <%Contact Email%><br>
etc., for the rest of the fields.

That's it.
Quote Reply
Re: [socrates] add confirm routine to sort field by name In reply to
Glad you got it figured out! Smile
Thanks for posting the solution.


Leonard
aka PerlFlunkie