Gossamer Forum
Home : Products : DBMan : Customization :

conditional html records output

Quote Reply
conditional html records output
I am hoping there's a way to do this and any help would be much appreciated.

EXAMPLE:
search for field(linking value) contains 36
-------
in the search results, I need to conditionally display record fields based on the following:
If field(ecat1)=search term(36), then field(edesc1)
If field(ecat2=search term(36), then field(edesc2)
If field(ecat3)=search term(36), then field(edesc3)

I would like to put this equation in the html_record section of the html.pl but I can't figure out how to do it.

Thanks for your help!

Monty Lewis
Quote Reply
Re: [mlewis] conditional html records output In reply to
I'm not sure I understand what you are trying to do?

Does each record contain each of the descriptions (edesc1, edesc2, and edesc3)?

Perhaps if you explained it in another way it might be easier to understand what you are wanting to do. Or someone else might understand it :)

Please check the FAQ under the section "Viewing/Conditional" for a thread called "Adding a category specific message in results page" as this might help with what you are trying to do.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [mlewis] conditional html records output In reply to
Do you mean?:
Code:
if ($rec{'ecat1'} eq "$in{'keyword'}") {
print qq|$rec{'edesc1'}|;
}

chmod
Quote Reply
Re: [LoisC] conditional html records output In reply to
In Reply To:
Does each record contain each of the descriptions (edesc1, edesc2, and edesc3)?

Yes, each record has those 3 fields. Each record also has ecat1, ecat2, and ecat3 which are used to identify which numbered category the text in edesc1...edesc3 apply to. So I want to conditionally display their values based on whether its ecat field matches the search term.

Thanks!
Quote Reply
Re: [chmod] conditional html records output In reply to
In Reply To:
Do you mean?:
Code:
if ($rec{'ecat1'} eq "$in{'keyword'}") {
print qq|$rec{'edesc1'}|;
}

chmod

chmod,
I think so. If my search term looks like ...linking_cat=36... does "$in{'keyword'}" refer to that value?

Using your suggestion, I can't get it to return any values.

Thanks for your help,
monty
Quote Reply
Re: [mlewis] conditional html records output In reply to
my code says if whatever is in field ecat1 matches the search term then display whatever is in field edesc1.

this would be of course in sub html_record, hope that helps

chmod
Quote Reply
Re: [chmod] conditional html records output In reply to
so I strung together your code as follows:

if ($rec{'ecat1'} eq "$in{'keyword'}") {
print qq|$rec{'edesc1'}|;
}
if ($rec{'ecat2'} eq "$in{'keyword'}") {
print qq|$rec{'edesc2'}|;
}
if ($rec{'ecat3'} eq "$in{'keyword'}") {
print qq|$rec{'edesc3'}|;
}


but I cant get it to return anything.
Is there a way I can get it to display "$in{'keyword'}" so I can see what's happening?

thanks, monty
Quote Reply
Re: [mlewis] conditional html records output In reply to
print $in{keyword}; Cool

Make sure you print a header first.
Quote Reply
Re: [mlewis] conditional html records output In reply to
You would also need to use the conditional statements as stated in the referenced thread I provided above:

|; # to close off a previous print qq| statement
if (condition) {
print qq|whatever|;
}
elsif (condition) {
print qq|something else|;
}
else {
print qq|another something|;
}
print qq|

using elsif and else.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [Paul] conditional html records output In reply to
thanks. that was easy. however, it seems my "$in{'keyword'}" is undefined, could that be? the value i'm passing into the script is:

?db=default&uid=&ID=&linking_cat=53&so=ascend&view_records=View+Records&nh=1

where linking_cat is the field I'm comparing to. It's correctly returning records, but if I print $in{'keyword'} it comes up empty.

and thanks Lois for the elsif/else note.

thanks, monty
Quote Reply
Re: [mlewis] conditional html records output In reply to
For $in{keyword} to print anything you'd need to add it onto that URL...eg...

&keyword=Blah

Last edited by:

Paul: May 4, 2002, 12:06 PM
Quote Reply
Re: [Paul] conditional html records output In reply to
I see. Thanks, Paul. How would I compare the search term used in my example, where I'm comparing the value in a single field and not doing a keyword search? (My understanding is that a keyword search is a search across all fields, is that right?)
Quote Reply
Re: [mlewis] conditional html records output In reply to
You are correct a keyword search does search across all fields.

I think you need to think more in terms of setting up your display for different views called through your link. That is why I was confused at first is because you were saying link and search.

You should explore the various threads in the FAQ under the sections viewing and searching. I think you will find a solution there.

For instance perhaps the following threads may help:

Viewing - Displaying sections on separate pages (record 980)

Linking - Simple special case from url (record 42)

I'm sure there are others which will give you ideas.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/