Gossamer Forum
Home : Products : DBMan : Customization :

Passing variables?

Quote Reply
Passing variables?
Hopes this makes sense.
Trying to have a picture show on a separate page linked off the main view record. Created another sub call in db.cgi, but got lost in bringing the variables to the new screen. I also will have up to 4 pictures if there are that many with "if else" calls. That part is no problem. To get an idea here is the link to the page.
http://www.tejasdesign.com/cgi-tejasdesign/riverhill/db.cgi?db=ranch&uid=default&ID=4&format=long&view_records=1
Any ideas?
Quote Reply
Re: Passing variables? In reply to
Where are the names of the graphics stored? Within the record, as in fields named Graphic1, Graphic2, Graphic3, Graphic4?

If so, make your link the the photo page something like

<a href="$db_script_link_url&db_key=$rec{$db_key}&show_pic=1">Look at the pictures</a>

In db.cgi, sub main, where all the other "elsif" statements are, add

Code:
elsif ($in{'show_pic'}) { if ($per_view) { &html_show_pic; } else { &html_unauth; } }

Then, in html.pl add a new subroutine:

Code:
sub show_pic {
%rec = &get_record($in{$db_key});

&html_print_headers;

[print the formatting for the top of the page]

if ($rec{'Graphic1'}) {
print qq|<img src="Graphic1">|;
}

[etc.]

[print the bottom of the page: footer and closing html tags]

}


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





Quote Reply
Re: Passing variables? In reply to
Ok, Had most of what you had, but still not passing the variable. Your info is what I needed, but no Cigar...
Here is a text file of what I have if you want to take a look at it.
http://www.tejasdesign.com/riverhill/my.txt

Just found out that the new IE 5.0 rendered the txt file as html, till I did a refresh.??
Quote Reply
Re: Passing variables? In reply to
What variable are you trying to pass?

(I can never figure out what's going on with IE. I only use it when I absolutely have to.)



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





Quote Reply
Re: Passing variables? In reply to
Well, the main ones will be.
Show_Pic_1

and
Picture_1
They are just the Caption and the jpg name.

I just DL IE 5.0 last week and like you never was a fan of IE, always NS, but now we have the option of only the browser and uninstall back to what you had if you choose. I sort of like it so far. Now watch the stones come flying.
Thank you for taking the time to look at this.
Quote Reply
Re: Passing variables? In reply to
But if your caption and graphic file are contained within the record, you don't need to pass those variables. You only need to pass the $db_key value. Then, in the show_pic subroutine, it uses the $db_key value to get the record, and, with it, the caption(s) and name(s) of the graphic file(s).

Or am I completely missing what you want to do?

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





Quote Reply
Re: Passing variables? In reply to
Your correct. It should be bringing up the variables from the record. It seems like I am missing something but can't put my finger on it. Well, let me keep working on it and thanks for your help. I get this solved and I will be almost done with this one. Already mapping out the next one.
Quote Reply
Re: Passing variables? In reply to
I made an error in what I'd posted earlier, which might be the answer you need.

Instead of

print qq|<img src="Graphic1">|;

it should be

print qq|<img src="$rec{'Graphic1'}">|;

Does that help?

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





Quote Reply
Re: Passing variables? In reply to
Nope, sorry. I seen that anyway. But now I am just putting in any variable from the record to get it to print. So not to worry about pictures, just get the record in there so I can read the variables. Going to eat now.. Then maybe in the morning head will be clear.
Thanks again.
Quote Reply
Re: Passing variables? In reply to
In general, if you want to pass a variable through a URL, use the syntax

&variable=value

When you refer to the variable, use

$in{'variable'}

The only problem you can come up with is if your "value" has spaces or other characters that might mess up a URL. If it's likely that the value will just have spaces, use

$variable =~ s/ /+/g;

and

&variable=$variable

If it's likely that the value will have other characters which might be a problem in a URL, you'll need to encode it. I can give you that, too, if you want it.

Make sense?

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





Quote Reply
Re: Passing variables? In reply to
Well, I'm using your mod for mailing a user (something like the above), and my $db_key value is not passed well...

What I get is '<B>db_key</B><B></B>' where db_key is the right key number...

i.e. if the key number I'd like to mail 135, i will get <B>135</B><B></B> ... I really don't know why...
Quote Reply
Re: Passing variables? In reply to
Turn off $db_bold in your .cfg file.


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





Quote Reply
Re: Passing variables? In reply to
Tnx.

Concerning your photo mod, could you please teel me how to make that if there is no pic, the link "Click for photo" don't show.

Quote Reply
Re: Passing variables? In reply to
Sure.

If your the names of your graphics are in fields and if the fields are empty if there's no graphic, you can have

if ($rec{'Graphic1'}) {
print qq|<a href="$db_script_link_url&db_key=$rec{$db_key}&show_pic=1">Click for photo</a>|;
}

This assumes that, if there is at least one graphic, the name will be in the Graphic1 field (which is probably the best way to set it up).

On a side note, if you want to turn $db_bold back on, you can still have the links come out all right. Before you put in the code I gave you above, add a line

$rec{$db_key} =~ s/<.?B>//g;

This will delete the <B> and </B> tags from the $db_key and your link should work okay.

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





Quote Reply
Re: Passing variables? In reply to
Stumbles and JPD, I know where the prob was with not passing variables.


JPD, you wrote <a href="$db_script_link_url&db_key=$rec{$db_key}&show_pic=1">Look at the pictures</a>


but there is missing one '$' just before db_key...


The correct link should be :
<a href="$db_script_link_url&$db_key=$rec{$db_key}&show_pic=1">Look at the pictures</a>


Ok, now let's get back to the track... the IF statement doesn;t work for me... It always shows "Click for photo" no matter if the my $rec{'Photo'} cointains, or doesn't contain anything... Damn... It's just killing me...

Quote Reply
Re: Passing variables? In reply to
Tnx, JPD, you are the most helpfull user of this forum I've seen. Smile Btw. I;ve tried to search the forum for 'listing style' but the search keep returning 'no data in document'. And sometimes, it returns me Error 500. Alex, what's going on ?!
Quote Reply
Re: Passing variables? In reply to
Thank you for noticing that I'd missed a $ -- I do it all the time. You'd think I'd learn! Smile

I'm not sure what to say about the if statement not working. I think I'm going to need to ask you to give me the URL of your site, or at least for you to copy your html.pl page to an accessible directory so I can take a look at it.


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





Quote Reply
Re: Passing variables? In reply to
As a follow up on bringing a graphic up as
a separate screen, I have taken Alex's suggestion and used a Java script call to open a separate screen with the picture. The problem I had was that I wanted the visitor to have a quick way to exit or close
the screen. You would be surprised at how many do not use the X to close out and with out a tool bar or anything this would have
been annoying.
If some one wants to embellish on this be my guest.
The only draw back is you can not make a call for the ???.jpg with this setup if it is on another server.
Thanks JP and Alex for your input.

Where:
http://www.tejasdesign.com/cgi-tejasdesign/demo/db.cgi?db=ranch&uid=default&ID=1&format=long&view_records=1

<script language="Javascript">
<!-- Hide
function display(url) {
var s1 =
"<br><FORM><INPUT TYPE='BUTTON' VALUE='Close Window'" +
"onClick='self.close()'></center>" + "</body></html>"
var s2 =
"<html><head><title>Ranch Pictures</title></head>" + "<body bgcolor='#D0FFFD' " + "<br><center>" + "Picture is now Loading<br>"
popup =
window.open(url,'picture', 'width=400,height=350,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no')
popup.document.write(s2+'<img src="'+url+'" '+'border=2 alt="Picture loading">'+s1)
popup.document.close()

}
// -->
</script>

The call:
<a href="javascript:display('http://www.tejasdesign.com/demo/$rec{'Picture_1'}.jpg')">$rec{'Show_Pic_1'}</a>