Gossamer Forum
Home : Products : DBMan : Customization :

2 List All links and 2 displays

Quote Reply
2 List All links and 2 displays
Hello,
I looked at the postings at Lois's 'redundantcartridge.com' but could not found the clue or help I need.
I am using the relational setup and the short/long modification. All works well. I would like to add another List All Link (List All2) to the footer that would display a view that is different from the default List All link (formatting and records that would be included). Sounds simple but I have not been successful.
I would greatly appreciate any help.

Regards,
Chef Mars
Quote Reply
Re: [chefmars] 2 List All links and 2 displays In reply to
You didn't say whether you wanted your alternate display to also be long/short, but I'm going to assume it is.

In html.pl, create sub html_record_alt for your alternate short display and sub html_record_long_alt for your alternate long display.

In your link to your alternate view, add &alt_view=1 -- so it would look like this:

<A HREF="$db_script_link_url&view_records=1&$db_key=*&alt_view=1">List All in alternate view</A>

In sub html_view_success, change

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

else {
print qq|<p><$font>Your search returned <b>$db_total_hits</b> matches.</font>|;
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>"; }
$rec_count = 1;
print "<table>";
for (0 .. $numhits - 1) {
print "<tr>";
&html_record (&array_to_hash($_, @hits));
print "</tr>";
++$rec_count;
}
print "</table>";
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>";}
}


to

Code:

if ($maxhits == 1) {
if ($in{'alt_view'}) {
&html_record_long_alt(&array_to_hash(0, @hits));
}
else { &html_record_long(&array_to_hash(0, @hits));
}
}
else {
print qq|<p><$font>Your search returned <b>$db_total_hits</b> matches.</font>|;
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>"; }
$rec_count = 1;
print "<table>";
for (0 .. $numhits - 1) { print "<tr>";
if ($in{'alt_view'}) {
&html_record_alt (&array_to_hash($_, @hits));
}
else {
&html_record (&array_to_hash($_, @hits));
}
print "</tr>";
++$rec_count;
}
print "</table>";
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>";}
}


That should do it.

(Edited to try to clean up the code. It looked really nice when I typed it.)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

Last edited by:

JPDeni: Jun 21, 2005, 8:14 PM
Quote Reply
Re: [JPDeni] 2 List All links and 2 displays In reply to
Thank you very much for your prompt response to my posting. I made the changes you suggested but it is not giving me the response-action I would anticipated. The code changes I made following your
suggestions send me to the search form and not another short URL list (with links to the long form). One reason
could be that I have included many of your MODS in the script. For instance my
code begins:

if (($db_total_hits == 1) || ($maxhits == 1)) {
&html_record_long(&array_to_hash(0, @hits));
Not with:
if ($maxhits == 1)

My goal is simply to add a second 'List All' (List All Alt. Items) link in the
footer and when the user clicks on it - it will act the same way as the current
'List All' link does, but bring up a short display list that looks exactly like
the one 'List All' displays BUT has as its link a URL that will display the
selected record in a different format than when they use the List All link.

If you would take a look at it I would appreciate it plus I think it would be
helpful. The 'List All Alt. Items' link is the one with the modifications I
made following your suggestions. The 'List All" link is the original one.

URL: http://www.marscafe.com/cgi-bin/dbman/xchg/db.cgi
User ID is: guest
password is: yulawiha

The script/database entries are just test entries at this point.

I know you are very busy, so if you can spare the time is would be much
appreciated. Getting this hurdle out of the way is important for me, but I need
help to leap it.

Regards,

Chef Mars



Delete | Reply | Reply to All | Forward | Redirect | Blacklist | Message Source | Save as | Print Back to INBOX Next Message
Move | Copy
Quote Reply
Re: [chef mars] 2 List All links and 2 displays In reply to
Quote:
My goal is simply to add a second 'List All' (List All Alt. Items) link in the
footer and when the user clicks on it - it will act the same way as the current 'List All' link does, but bring up a short display list that looks exactly like
the one 'List All' displays BUT has as its link a URL that will display the
selected record in a different format than when they use the List All link.


Your problem is in your link. When I looked at the source, I found this for the List All Alt link:

&view_records=1&sb=2&so=ascend&alt_view&ItemID=1=*

It needs to be

&view_records=1&sb=2&so=ascend&alt_view=1&ItemID=*

When I moved the text around within the URL, I think I got what you want. It's hard to tell because I don't know for sure what the main and alternate views are supposed to be. While testing it, I would suggest putting something that says "This is the alternate view" and "This is the main view" in the subroutines just so you can be completely clear about what you're getting.

If you're having trouble with the syntax of the List All link, post what you have in your script and I'll see if I can help you with it.

As for the rest of it, it should work. You may not need the extra "if" statement that I gave you at the beginning, but the "alt_view" flag should be passed on if it was originally clicked and not passed if it wasn't originally clicked. That's what all that URL stuff at the beginning of the subroutines in the short/long display mod is all about. Well, actually it's all about passing along search terms, but it works for this, too. :-)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] 2 List All links and 2 displays In reply to
JD Peni,

Thank you for the consideration and help. With the clues and examples you gave me I have been able to "achieve my goal". In fact, I added two additional views and can add as many more as needed. I am including the relevant final code from format.pl and item_html.pl. I have left the guest user operational if you or anyone wants to take a look.

Once again thank you for helping me, and many others.

Regards,
Chef Mars




format.pl

sub html_footer
---------------
print qq!| <A HREF="$db_script_url?db=item&uid=$db_uid&view_records=1&sb=2&so=ascend&alt_view=1&ItemID=*">ALTERNATIVE VIEW</A> ! if ($per_view);

print qq!| <A HREF="$db_script_url?db=item&uid=$db_uid&view_records=1&sb=2&so=ascend&alt2_view=1&ItemID=*">ALTERNATIVE 2 VIEW</A> ! if ($per_view);


================================================================================

item_html.pl

sub html_view_success
--------------------

if ($maxhits == 1) {
if ($in{'alt_view'}) {
&html_record_long_alt(&array_to_hash(0, @hits));
}
elsif ($in{'alt2_view'}) {
&html_record_long_alt2(&array_to_hash(0, @hits));
}
else { &html_record_long(&array_to_hash(0, @hits));
}
}
else {
print qq|<p><$font>Your search returned <b>$db_total_hits</b> matches.</font>|;
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>"; }
$rec_count = 1;
print "<table>";
for (0 .. $numhits - 1) { print "<tr>";
if ($in{'alt_view'}) {
&html_record_alt (&array_to_hash($_, @hits));
}
elsif ($in{'alt2_view'}) {
&html_record_alt2 (&array_to_hash($_, @hits));
}
else {
&html_record (&array_to_hash($_, @hits));
}
print "</tr>";
++$rec_count;
}
print "</table>";
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>";}
}