Gossamer Forum
Home : Products : DBMan : Installation :

Link with Amazon.com

Quote Reply
Link with Amazon.com
I am interested in using DBMan as a way to build a searchable bookstore on my web site with links to Amazon.com. I am experimenting with the script now and am looking for a way to have the search results return a "Title" field as a linked url with the url I put in the field for "URL".

Next, on the search results I would like to exclude information such as "Type," "Date," ect... are either of these possible?

www.jungindex.net

[This message has been edited by nautis (edited December 30, 1998).]
Quote Reply
Re: Link with Amazon.com In reply to
JPDeni,

The link part is working, however the now the "Editor" field is showing up when there is no editor list. There is just the blank field with no name. The solution before got rid of the blank field problem, but now with the url solution, the blank field problem has come back. I am sure it is something simple I have forgotten. I have included a snip of the code I am working with from html.pl at sub html_record. If you see any errors please let me know. I have moved ahead light years thanks to you. I hope that posting the code will help fix the mess I have created.

----

print qq|

<TABLE WIDTH="640" CELLPADDING=0 CELLSPACING=2 BORDER=0>
<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Title:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font><B><a href="$rec{'URL'}">$rec{'Title'}</a></B></Font></TD></TR>


|;


if ( $rec{'AuthorURL'} ) {
print qq|<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Author:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font><a href="$rec{'AuthorURL'}">$rec{'Author'}</a></Font></TD></TR>|;
}
else {
print qq|<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Author:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font>$rec{'Author'}</a></Font></TD></TR>|;
}

if ( $rec{'EditorURL'} ) {
print qq|<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Editor:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font><a href="$rec{'EditorURL'}">$rec{'Editor'}</a></Font></TD></TR>|;
}
else {
print qq|<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Editor:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font>$rec{'Editor'}</a></Font></TD></TR>|;
}

if ( $rec{'ReviewURL'} ) {
print qq|<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Review:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font><a href="$rec{'ReviewURL'}">$rec{'Review'}</a></Font></TD></TR>|;
}
else {
print qq|<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Review:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font>$rec{'Review'}</a></Font></TD></TR>|;
}


print qq|


<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Description:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font>$rec{'Description'}</Font></TD></TR></TABLE>
|;
}

-----
Quote Reply
Re: Link with Amazon.com In reply to
JPDeni,

Thanks. It works! I had set $db_auto_generate to 1, so I was a little confused, but it is now working just fine. Since you seem like you really know this program well, I would like to ask another question, if you don't mind.

I have set many of the fields as optional. For example, not all book have editors, most have only one author. But, since some books do have editors I would like to make this an available field. However, I do not want to have a blank field show up on ever search for a book with an author that is an editor field. In other words, is there a way to have only the called, or filled in fields show up in a search?
Quote Reply
Re: Link with Amazon.com In reply to
I seem, at least for the time being, to have made DBMan my life's work! Smile

Quote:
is there a way to have only the called, or filled in fields show up in a search?

Yep. But it takes a little more doing.

In html_record, when you come to an optional field, first close off the previous

print qq|

with a

|; (that's a "pipe character" and a "semi-colon")

Then add, for example,

if ( $rec{'Editor'} ) {
print qq|<TR><TD>Editor:</TD><TD>$rec{'Editor'}</TD><TR>|;
}


If the next field is a required field, start it with

print qq|

and just continue your record from there.


------------------
JPD
Quote Reply
Re: Link with Amazon.com In reply to
JPDeni,

Again, it worked! Thank you so much. Now I am trying to do something similar that will probably have a similar solution.

I have created an AuthorURL and an Author field. I would like to have a link that refers to the authors home page, if they have one. However, right now when there is no url given in the form, it is defaulting to my $db_dir_url and creating a link anyway. Is there a way to make the link highlight as a link when I have entered one, and to not highlight when I have not entered a link?

This is what I have now.
<$font_color>Author:</FONT><$font><a href="$rec{'AuthorURL'}">$rec{'Author'}</a></Font>

Thanks again for all your help...

- Matthew
http://www.jungindex.net/

Quote Reply
Re: Link with Amazon.com In reply to
Glad this is working for you. It wasn't that long ago that I had questions similar to yours, so I really understand.

Okay, so the AuthorURL thing.

First, be sure to close off the previous print qq| like I said earlier. (I don't mean to harp on this, but this is what I kept forgetting to do and your script won't compile if you forget.)

The syntax is

if ( $rec{'AuthorURL'} ) {
print qq|<$font_color>Author:</FONT><$font><a
href="$rec{'AuthorURL'}">$rec{'Author'}</a></Font>|;
}
else {
print qq|<$font_color>Author:</FONT><$font>$rec{'Author'}</a></Font>|;
}


You will need to be sure the AuthorURL field is empty if there isn't a web page for the author. IOW, take out the default of your website in the .cfg file. (I'm sure you already knew that, but I try to be thorough. Smile )




------------------
JPD
Quote Reply
Re: Link with Amazon.com In reply to
 
Quote:
the search results return a "Title" field as a linked url with the url I put in the field for "URL".

<a href="$rec{'URL'}">$rec{'Title'}</a>

Quote:
on the search results I would like to exclude information such as "Type," "Date,"
ect.

Sure. You can choose to display any fields you want in the html_record subroutine. If you would like to have more than one html_record -- one with minimal detail and one with the full record -- do a search here on the forum for "long and short listings." (I'm pretty sure you'll come up with something using that phrase. You may have to play with your search terms a little.)



------------------
JPD
Quote Reply
Re: Link with Amazon.com In reply to
You need to nest the "if" statements:

if ( $rec{'Editor') {
if ( $rec{'EditorURL'} ) {
print qq|<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Editor:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font><a
href="$rec{'EditorURL'}">$rec{'Editor'}</a></Font></TD></TR>|;
}
else {
print qq|<TR><TD bgcolor="#e8e8e8" ALIGN="Right" VALIGN="TOP"><$font_color>Editor:</FONT></TD>
<TD bgcolor="#f8f8f8"><$font>$rec{'Editor'}</a></Font></TD></TR>|;
}
}


I can see that things are coming along for you! Smile


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


[This message has been edited by JPDeni (edited December 31, 1998).]
Quote Reply
Re: Link with Amazon.com In reply to
It works... Thanks for all your help.

Does anyone know how to do this...
I would like to have one of three graphics come up next to the title, depending on whether the "Type" is book, video or audio tape. In Links I know there is hack that you can use to create the new! graphic. Is there a way to do this with DDMan?
Quote Reply
Re: Link with Amazon.com In reply to
Ask and you shall receive. Smile

Quote:
I would like to have one of three graphics come up next to the title, depending on whether the "Type" is book, video or audio tape.

If ( $rec{'Type'} eq 'Book' ) {
print qq|<img src="http://www.server.com/full/URL/to/book.gif">|;
}
elsif ( $rec{'Type'} eq 'Video' ) {
print qq|<img src="http://www.YouGetTheIdea/video.gif">|;
}
elsif ( $red{'Type'} eq 'Audio' ) {
print qq|<img src="http://etc/audio.gif">|;
}


If there are only three possibilities -- and this is a required field so you know something will be in it -- you can change the last "elsif" statement to

else { print qq|etc.|; }

Anything else? Smile



------------------
JPD
Quote Reply
Re: Link with Amazon.com In reply to
JPDeni,

Yes, of course, your hack works again. Sorry I did not respond sooner, I have been away from my computer. I now get a graphic display of book, video, or audio tape, depending on the 'type' of format I enter. Very cool! Thank you so much.

Now, I have a another request. Maybe this one will be more of a challenge, a curve ball. You know, you are batting 1000. I would like to display another graphic, this time, the scanned book cover, a 87x140 thumbnail with a link to the full 292x475 cover graphic. So, each time there is an available scanned book cover, the thumbnail will appear next to the title with an href to the larger, full image. Is this possible?

I was looking around Invincible Summer. It is really remarkable. We have more than DBMan in common. We both received an award from Mental Health Net because we have web site on mental health.

I am interested in how you developed the database to reach so deep. For example, when I click on the title of a writing I am taken to a deeper level which displays the writing with the author's name, ect, all within the DBMan template. How did you do this. If this is a big question, you can just refer me to something to read further, rather than try to explain it.

[This message has been edited by nautis (edited January 04, 1999).]
Quote Reply
Re: Link with Amazon.com In reply to
I put together a mod that will do the simple/detailed output.

You will find it here:

http://www.gossamer-threads.com/scripts/forum/resources/Forum5/HTML/000148.html
Quote Reply
Re: Link with Amazon.com In reply to
Thank you for the compliments on my site. You sure seemed to have looked around a lot.

Take a look at Norm's "simple/detailed" output mod. I think it's pretty much the same as mine. I got the idea when he asked for help on it here.

Quote:
Now, I have a another request. Maybe this one will be more of a challenge, a curve
ball. You know, you are batting 1000. I would like to display another graphic, this time,
the scanned book cover, a 87x140 thumbnail with a link to the full 292x475 cover
graphic. So, each time there is an available scanned book cover, the thumbnail will appear next to the title with an href to the larger, full image. Is this possible?

Sure! Most anything's possible! Smile

I'm going to make some assumptions in my explanation. First, that you name the thumbnail .gif by the name of the key for that record plus "sm" -- so if your key for the record was "1234," the thumbnail .gif would be "1234sm.gif." The large one would be "1234lg.gif." Also, that you have a field in your db called "Thumbnail" which is either a "Yes" or empty -- probably a checkbox field. If you have a thumbnail available, you would enter "Yes" in that field. (Actually, you could have it equal anything you want.)

Also for shorthand purposes, I'm going to assume that you have defined a variable called $graphic_directory, which is the full URL to the directory where all your graphics are. Define it at the top of the html.pl file under
# Put any globals you like in here for your html pages.
It would be something like:
$graphic_directory = 'http://www.yourserver.com/graphics';

Now, in html_record, where you want your thumbnail to appear, add:

if ( $rec{'Thumbnail'} ) {
print qq|<a href="$graphic_directory/$rec{$db_key}lg.gif"><img src="$graphic_directory/$rec{$db_key}sm.gif width=87 height=140 border=0 alt="$rec{'Title'}></a>|;
}


You don't have to add the "alt" tag, but it's kinda nice to have.

There's other ways to do it, by entering the name of the thumbnail and the large .gif files in your db, but this is the easiest way, IMO.

I sure want to see your site when it's all finished! Smile



------------------
JPD
Quote Reply
Re: Link with Amazon.com In reply to
Hi,

Thanks Norm and JPDeni. I tried both solutions. The simple/detailed output solution I think is really beyond me. Is the text of the page entered into a form? What if I have an entire book chapter to be printed? Is there a way to do this? I know that web forms have character limits.

JPDeni, I tried the solution you sent, but I am not sure how to configure my sub html_record_form for this. You suggested I use a yes/no option to display the cover graphic. I am not quite sure how to do this. My lack of skills is probably becoming pretty obvious about right now. Oh well, I'm learning thanks to your help...
Quote Reply
Re: Link with Amazon.com In reply to
 
Quote:
I tried the solution you sent, but I am n1ot sure how to configure my sub html_record_form for this. You suggested I use a yes/no option to display the cover
graphic. I am not quite sure how to do this.

Okay. Add a field in your .cfg file called "Thumbnail." Do not make it a required field. Then, a little further down, look for
%db_checkbox_fields = ( Popular => 'Yes' );

Change the word "Popular" to "Thumbnail."

Then, in sub html_record_form, where you want to have the checkbox appear, enter

|; print &build_checkbox_field ("Thumbnail", "$rec{'Thumbnail'}"); print qq|

This is exactly the same as in the default html.pl file subroutine, except I've changed "Popular" to "Thumbnail."

Quote:
The simple/detailed output solution I
think is really beyond me. Is the text of the page entered into a form? What if I have an entire book chapter to be printed? Is there a way to do this? I know that web forms have character limits.

I gave my solution to terewong earlier today. I can't remember the subject line for certain -- something about "Adding Data." Look down the list of subjects and find one started by terewong. There aren't too many. Smile


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