Gossamer Forum
Home : Products : DBMan : Customization :

Form layout based on search results

Quote Reply
Form layout based on search results
The following question is based on the discussion we had the thread, "Mod for different search results???" at:

http://www.gossamer-threads.com/...m12/HTML/000120.html

I've set up the short form and it works fine. Thanks for all the help! Here's what I would like to do:

I would like to be able to display a 'custom' html_record_short depending on what the search criteria was. As it stands now I have one html_record_short set up in my html.pl file and no matter what the search was, the same table layout will be displayed.

Is there a way in which I can change the content of the table to include some basic information plus generate and display a column with the field the user specified in his/her search criteria?

Let's assume I have 10 fields in each record. My standard html_record_short is set up to show only fields 1,2, and 3 and a link to show the complete record. A user enters search criteria in field 7 on the search form, and asks that it be sorted by field 5 - descending! (Still with me?)

I would like my html_record_short output to now show, Fields 1,2,3 (as always) and include field 7 (searched on) and field 5 (sorted by)....and of course the link to see the full record.

Any suggestions? This rocks - I'm having fun while learning a stack!


------------------
Safe swoops
Sangiro

http://www.dropzone.com/
Quote Reply
Re: Form layout based on search results In reply to
It would be a little complicated, but you could do it. Something like

Code:
if ($in{'field7'}) {
print "$rec{'field7'}";
}
elsif ($in{'sb'} == 7) {
print "$rec{'field7'}";
}

You'd need to do that for each of the fields that people can search on (aside from the ones that are in your short display by default).

The reason for the if -- elsif structure is so if they sort on the same field they're searching on, it won't display twice.


------------------
JPD





Quote Reply
Re: Form layout based on search results In reply to
JPD,

I'm assuming I'll need to work this into my sub html_view_success? How should I change my sub html_record_short to prevent it from printing the static information I have in that and to customize the output? (Or was my original assumption wrong?)



------------------
Safe swoops
Sangiro

http://www.dropzone.com/
Quote Reply
Re: Form layout based on search results In reply to
OK - my assumption was wrong! I've worked it into the sub html_record_short and it seems to be working OK. Still a bit messy!

Here's another question:

How do I test for an empty field? For example, I have this line in that same subroutine:

Code:
<TD BGCOLOR="#EEEEFF" HEIGHT="25"><$font><A HREF="$rec{'Website'}"><B>$rec{'Dropzone'}</B></A></Font></TD>

This would cause a link to be created to the Dropzone even if they don't have a web site and there's only a http:// in the field.

This is what I would like to do:

1) print the Dropzone name - field 1
2) check if theres a web site URL in field 2
3) if so, link the name to it
4) if not, skip and print the next record

So, here's my effort!!

Code:
if ($rec{'Website'} == 'http://') {
print "<TD BGCOLOR="#EEEEFF" HEIGHT="25"><$font><B>$rec{'Dropzone'}</B></Font></TD>";
}
elsif ($rec{'Website'}) {
print "<TD BGCOLOR="#EEEEFF" HEIGHT="25"><$font><A HREF="$rec{'Website'}"><B>$rec{'Dropzone'}</B></A></Font></TD>";
}

All I've done is manage to black out the dropzone name and the next field - yes, you heard me, a big black block covers both!

Suggestions?






------------------
Safe swoops
Sangiro

http://www.dropzone.com/
Quote Reply
Re: Form layout based on search results In reply to
Yes, it does go in html_record_short.

I'm surprised that you got a big black block covering your fields. Not sure why. It could be problems with quotation marks. If you have quotation marks within a quoted string, you have to use the print qq| structure.

What I would do:

Code:
print qq|
<TD BGCOLOR="#EEEEFF" HEIGHT="25"><$font>
|;
if (length($rec{'Website'}) > 7) {
print qq|<A HREF="$rec{'Website'}">
<B>$rec{'Dropzone'}</B></A>|;
}
else {
print "<B>$rec{'Dropzone'}</B>";
}
print "</B></Font></TD>";

See the difference in the places where I use quotes and print qq| ?


------------------
JPD





Quote Reply
Re: Form layout based on search results In reply to
You're right. You can use
print "<a href=\"$db_script_link_url\">";

I find that it's hard to read that and that I'm likely to forget to put in the \s. Since the | is so rarely used, it's something that I've gotten used to using.

It's personal preference, though. If you can remember to use the \ before the ", and you like it better, go for it! Smile


------------------
JPD





Quote Reply
Re: Form layout based on search results In reply to
Heeyaa! Works great! What's the rationale in choosing when to use qq| and when print"?

I understand that I can use quotation marks in a qq| statement. I think I can also use them in a print" statement if I preceed them with \.

Any other reasons for picking the one above the other?



------------------
Safe swoops
Sangiro

http://www.dropzone.com/
Quote Reply
Re: Form layout based on search results In reply to
Heya JPD - remember me?

I've been having loads of fun with the database, did all the funky changes and modifications I wanted but I'm embarrassed to say I've lost myself again!

I've done the changes to sub html_record_short so as to show only the record fields I search for. I've made a similar modification to sub html_view_success to print only headers for those fields I'm searching for.

Problem is on viewing the records my database now return the 'full view' again in stead of the short view.

Any ideas on where I stuffed up?

http://www.dropzone.com/html_pl.txt



------------------
Safe swoops
Sangiro

http://www.dropzone.com/
Quote Reply
Re: Form layout based on search results In reply to
I'm afraid not. Your html.pl file is so complicated now that it would take me hours to sort through it.

It doesn't make any sense that you should be getting the long display when you have more than one record, though.

It does make me think of the one rule I live by, though. Only make one change at a time. Then test it thoroughly. Then make the next change. And test it thoroughly. It's a slow process, but it's the only way I've figured out how to find errors as I'm working.


------------------
JPD





Quote Reply
Re: Form layout based on search results In reply to
Okay. Let me look at the database itself. Maybe I can figure out what's going on then. I didn't save the info for the URL to the database that you sent me in email, so if you want to send it to me again, you can send it to hall@drizzle.com .


------------------
JPD





Quote Reply
Re: Form layout based on search results In reply to
JPD - you're breaking my heart! I'll try to debug it myself. Thanks

------------------
Safe swoops
Sangiro

http://www.dropzone.com/