Gossamer Forum
Home : Products : DBMan : Customization :

Short to long to another?

Quote Reply
Short to long to another?
Taking the lead from the short to long mod I am attempting to make another level of display.

I have taken the short to long mod and named it another subroutine and inserted that routine in the the long display (&html_extended_link).

I have then created another subroutine called html_extended_result.

It appears I am mangling something or missing the obvious, but my extended is linking back to long.

Putting me on the right course would be appreciated. I feel I am finaly getting this, but 5 hours in front of the screen I feel I need to to ask for a hint.

How can I link from the long display to another level?

Thank you !! :-)
Quote Reply
Re: Short to long to another? In reply to
What have you already done? No point in my re-inventing the wheel. Smile


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





Quote Reply
Re: Short to long to another? In reply to
Hi Carol,


Great to hear you are feeling better. Per your request hear is my really bad attempt at learning this stuff. Reinvent the wheel? At this point I feel as if I am on a square tire.


sub html_record_extended_link {
# --------------------------------------------------------

my (%rec) = @_;
$ext_url = $ENV{'QUERY_STRING'};
$ext_url = "$db_script_url?$ext_url&nh=$record_number&mh=1&html_record_extended";

print "<TD>"; # do not remove this! It is necessary to make the records display properly

# Below is where you define what you want to appear for each record in the "short" display.
# You can make this whatever you want, and display as many fields as you would like.
# Choose which of the fields you would like for users to click on to reach the full display
# of records and use that field name in place of "Title" below.
#
# Be sure that you use <a href="$long_url"> for the link to your full record display.

# <-- Start of short display formatting -- >

print qq|

<a href="$ext_url">$rec{'Company Name'}</a><P>

#<a href="$db_script_url?ext_url&html_record_extended=$record_number&mh=1">Click here</a>


|;

# if you want to display your fields in columns, use the following format:
# print qq|
# $rec{'Field'}</td>
# <td>$rec{'Field'}</td>
# <td>$rec{'Field'}</td>
# <td>$rec{'Field'}|;

# Add or remove columns as needed. Be sure you add the $long_url link to one of your fields

# <-- End of short display formatting -- >

print "</TD>"; # do not remove this! It is necessary to make the records display properly

}

Then I did:

sub html_record_extended {
#----------------------------------------------------------------
my (%rec) = @_; # Load any defaults to put in the VALUE field.
# ($db_auto_generate and print &build_html_record(%rec) and return);

if ($db_total_hits > 1) {

# create links to previous and next records

# $next_url = $ENV{'QUERY_STRING'};
# $next_url =~ s/\&nh=\d+//;
# $next_hit = $nh + 1;
# $prev_hit = $nh - 1;

if ($prev_hit) {
# $previous = qq~<a href="$db_script_url?$next_url&nh=$prev_hit"><$font>Previous</font></a>~;
}
else { $previous = " "; }

if ($next_hit <= $db_total_hits) {
# $next = qq~<a href="$db_script_url?$next_url&nh=$next_hit"><$font>Next</font></a>~;
}
else { $next = " "; }

# create link back to short display
$list_url = $next_url;
$list_url =~ s/\&mh=\d+//;
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
# $list = qq~<a href="$db_script_url?$list_url&nh=$lh"><$font>Back to record list</font></a>~;

# print out the links
# print qq| |; }

# Below is where you define your form.

# <-- Start of record display -->

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';


print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Company Name:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Company Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Contact Person:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Contact Person'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Address 1:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Address 1'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Address 2:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Address 2'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>City:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'City'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>State:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'State'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Zip:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Zip'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Country:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Country'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Phone:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Phone'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Fax:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Fax'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Email:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="mailto:$rec{'Email'}">$rec{'Email'}</a>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>URL:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="$rec{'URL'}">$rec{'URL'}</a>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Job Title:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Job Title'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Job Description:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Job Description'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Salary:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Salary'}</Font></TD></TR>
</TABLE>
|;
}
}


I know it is probably really wrong and I will delete it from this post so no one can make fun of me, but I am trying

Thank you!!!
Quote Reply
Re: Short to long to another? In reply to
 Smile You're doing okay with what you have, but there are some problems.

I want to see if I understand what you're doing correctly.

I go to your site.
I do a search.
I get a list of the "short" display.
I click on one.
I get the long display.
I click a link on the long display.
I get still more information from that record.

Is that correct?


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





Quote Reply
Re: Short to long to another? In reply to
That is exactly what I want to do. And I can not believe I am actually on the right track.

Can you give me hints yo my errors, or in general what I have to do different?

In one respect it owuld be great to just ask to have someone do it, but I really just want to learn from trial and error, so I can contribute one day.

Thnak you Carol!!!
Quote Reply
Re: Short to long to another? In reply to
You'll need a link, then, from your "long" display to your "extended" display. Do you have that?

I don't think you need your sub html_record_extended_link, because you're going to be moving from "long" to "extended."

What I would do is create a link in sub html_record_long.

After

Code:
$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&nh=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;

add

Code:
$ext_url = $ENV{'QUERY_STRING'} . "&extended=1";

And, in the place where you want to print out the link, use

Code:
<a href="$ext_url">Extended record</a>

Then, in sub html_view_success, change

Code:
if (($db_total_hits == 1) &#0124; &#0124; ($maxhits == 1)) {
&html_record_long(&array_to_hash(0, @hits));
}

to

Code:
if (($db_total_hits == 1) &#0124; &#0124; ($maxhits == 1)) {
if ($in{'extended'} {
&html_record_extended;
}
else {
&html_record_long(&array_to_hash(0, @hits));
}
}

At this point, you will have to use the back button on your browser to get back to the "long" display. Did you want to include links back to the original search results list and to be able to page through the search results using the extended display?


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





Quote Reply
Re: Short to long to another? In reply to
Thank you Carol.

I see what you mean. I have a problem though, I keep on getting an error with the

############
if (($db_total_hits == 1) | | ($maxhits == 1)) { if ($in{'extended'} { &html_record_extended; } else { &html_record_long(&array_to_hash(0, @hits)); } }

I have fixed the &#0124; &#0124; but still I get errors. It appears all brackets are equal, so I am stuck.

Thank you!!!
Quote Reply
Re: Short to long to another? In reply to
Looks like I messed something up. The code should be

Code:
if (($db_total_hits == 1) &#0124; &#0124; ($maxhits == 1)) {
if ($in{'extended'}) {
&html_record_extended(&array_to_hash(0, @hits));
}
else {
&html_record_long(&array_to_hash(0, @hits));
}
}

There were two problems. I had left out a closing parentheses and I had left out (&array_to_hash(0, @hits)) from the "extended" if statement. Give this a try.


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





Quote Reply
Re: Short to long to another? In reply to
I inserted the code and the 500 error stopped. I actually did what you told me to do on my own, by i was missing a bracket. I got to get those things down already.

Anyhow, when I click on the extended URL I get a page not found. I have looked over (in my own simple way) the code and it appears it should be working, Now I think my sub html_record_extended is wrong.

I have commented, reworked, but to no avail. I even have my Perl reference manual out!!

Any hints!?
Quote Reply
Re: Short to long to another? In reply to
Can I take a look at your database in action?

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





Quote Reply
Re: Short to long to another? In reply to
It is not to much to look at. I just got is up and there is no design. But here it is.
:-)

http://www.accessoriescouncil.com/cgi-bin/mem_dir/db
Quote Reply
Re: Short to long to another? In reply to
Actually, I'm glad that there's not much in the way of design on your site. It's much better to start with the functionality and make it pretty later.

I made a mistake in the code I gave you.

Code:
$ext_url = $ENV{'QUERY_STRING'} . "&extended=1";

should be

Code:
$ext_url = $db_script_url . "?" . $ENV{'QUERY_STRING'} . "&extended=1";

I think. Smile

If that doesn't work, try

Code:
$ext_url = $db_script_url . $ENV{'QUERY_STRING'} . "&extended=1";

(I'm not sure whether you need to add the ? to the URL or not. If you end up with two question marks, use the second code I gave you.)


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





Quote Reply
Re: Short to long to another? In reply to
$ext_url = $db_script_url . "?" . $ENV{'QUERY_STRING'} . "&extended=1";

PERFECT!!!

So, ext_url is actually saying to grab the scalar and join with the "?" to query with the current routine and join with my new sub?!!

OK. I think I am going to play with this more. Once I see it it makes sense. i cant wait till the day I can just do it.

Thank You!!
Quote Reply
Re: Short to long to another? In reply to
It does take a bit of working with it to "get" it, but it is all very logical.

You understand the process perfectly! Smile



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





Quote Reply
Re: Short to long to another? In reply to
I have added this mod to my DBman and I was wondering if there is a way to have the 3rd tier of display to escape the header/footer so it will just show the text -- like a print view. "extended url" currently goes to sub html_view_success which has the header/footer info in it. Can the extended url be routed to something other than html_view_success?

Any input is appreciated!

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Short to long to another? In reply to
Hi there,

I was trying to get a third level of display to, so i did the things mentioned above.

But now i get a cgi-error:

CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: syntax error at /opt/guide/www.tg-design.nl/cgi-bin/DBMan/html.pl line 637, near "| |"

Can anyone help me, thanx...
Quote Reply
Re: Short to long to another? In reply to
Thijs,

just remove the spaces between the two | | characters.

The board tends to space them out when people post code. That should fix your problem.

------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!