Gossamer Forum
Home : Products : DBMan : Installation :

New Short Display Works Great!

Quote Reply
New Short Display Works Great!
Hi there!

I just loaded your new short.txt after reading about it in another thread and it works great!

We would like just one mod, however.

We need to make the "List All" function perform a specialized sort by category, print the category as a title, and list the records within that category alphabetically before doing the same with the next category, and so on.

Your help would be greatly appreciated!

Thanks again,

------------------
BigBritchs
BigBritchs@IDunno4Recipes.com

Quote Reply
Re: New Short Display Works Great! In reply to
I'm glad you like the short display mod. That took me a while to conceptualize. Smile

What you want is to "group by" and I don't know how to do it. I have some ideas, but nothing solid enough to give you now.


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





Quote Reply
Re: New Short Display Works Great! In reply to
Thanks again for the short display.

See what you can do and I'll consider the terms specified in your email to me fulfilled and I'll follow through by doing my part.

I hope that's too abstruse! Wink

Regards,

------------------
BigBritchs
BigBritchs@IDunno4Recipes.com



[This message has been edited by BigBritchs (edited June 03, 1999).]
Quote Reply
Re: New Short Display Works Great! In reply to
I made this mod a while ago so I can't quite explain it all but perhaps you can get the jist of it from this post. What this does for me is groups by Category. Basically I define the $last_category and then check to see if the category has changed, if it has then print a new category header and carry on. Probably sloppy but it does the trick. There may also be some junk in there as I like to experiment with my Perl knowledge(pretty limited). You'll have to decipher the good from the bad.

sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
$rec{'Quote'} =~ s/\n/<br>/g;
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
if ($rec{'Category'} ne $last_category ){
&tmp_category(%rec);
}
print qq|<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="ffffff">
<FONT FACE="MS Sans Serif, arial,helvetica" size=2 COLOR="#000000">
<center><br>$rec{'Quote'}<br></center><p>Submitted: $rec{'Date'}</p>
</td></tr></table>|;
$last_category=$rec{'Category'}

}
sub tmp_category{
$in{$db_key} = "*";
my ($status,@hits)=&query();
for (0 .. $db_total_hits - 1) {
%tmp = &array_to_hash($_, @hits);
++$count{$tmp{'Category'}};
}

my (%rec) = @_;
#($db_auto_generate and print &build_html_record(%rec) and return);
$tmp_category=$rec{'Category'};

print qq|<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=2 COLOR="#FFFFFF">
<b><center><em>$tmp_category</em></center></b>
</td></tr></table>|;
}


[This message has been edited by mike1 (edited June 06, 1999).]
Quote Reply
Re: New Short Display Works Great! In reply to
All that matters is that it works! Smile

How are you being sure your items are grouped together by category? Did you use my "sorting field" method or something else?


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





Quote Reply
Re: New Short Display Works Great! In reply to
I forgot to mention that the sb always has to be set to the 'Category' field in order for my version to work

Mike

http://www.altainfo.com/toastmasters/cgi-bin/quote/db.cgi?uid=default&view_records=1&sb=2&ID=*&nh=2
Quote Reply
Re: New Short Display Works Great! In reply to
Very nice! Smile

I see that you don't sort within the categories, so you don't need to worry about the "sorting field" thing.

I might go about it a little different way, but, as I say, so long as it works, it's okay. Smile


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