Gossamer Forum
Home : Products : DBMan : Customization :

Group Short Display by Category

Quote Reply
Group Short Display by Category
I have setup the short/long display, and I like it very much. I would like to take it a step further, by adding a category header to the short display. When the category name changes, it would start a new table, with the new category name. I have tried to implement a piece of code that someone here posted a while back, in which they were trying something similiar, but I cannot figure out were to call the new category sub in &html_view_success. It will only print the new category name at the beginning of a new page, rather than restarting a new table in the middle of the page. Can anyone help me out a little here?
Quote Reply
Re: Group Short Display by Category In reply to
Sorry for the confusion. Here is what is going on: In html_view_success of the short/long display mod, I included the code from one of your postings to allow sorting by different fields. This is the code between the == lines. I modified it to include a button in the same row as the sort by fields, to allow a user to kick-off another script, being supplied with the values the user selected from the input boxes.The code evaluates the value of the 'part' field for each record and determines whether or not to print a checkbox or the word "None". This has not changed the basic default look of the short/long display mod though.
Yes this is for viewing search results.I just realized that the
&tmp_category(&array_to_hash($_, @hits));
if($rec{'Selection'} ne $tmp_category) {
&tmp_category;
}
probably needs to be before my <FORM> tag, in a table row, to be evaluated each time a record is printed, but when I tried that it prints everything in one column.The &tmp_category sub just gets the current category name for the current record. I hope this is a little clearer now.
Quote Reply
Re: Group Short Display by Category In reply to
Okay. Well, I still don't really understand, but I think I can get you want you need.

I'm going to assume you don't have all the other stuff and give you what I think will work. The rest of it, I'm afraid will be up to you.

You know that dire warning I have in the "short" display --

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

Add the following before that line:

Code:
unless ($last_category eq $rec{'Category'}) {
print qq|<td colspan=4>$rec{'Category'}</td></tr><tr>|;
$last_category = $rec{'Category'};
}

(I think I counted 4 cells across. If I miscounted, change the colspan number to the numer of cells you have.)

I'm not sure what this will do to the modify and delete forms, though.


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





Quote Reply
Re: Group Short Display by Category In reply to
Thanks, that is getting me closer to what I need. I didn't think to change anything in this part of the code. I had to add a <tr> tag after the print qq| to get the category name to appear in a row by itself. It looks like though the new category name is printing after the first record with a new category name instead of before it.Should this be located above print "<TD>"; # do not remove this! It is necessary to make the records display properly in the short display section?
Quote Reply
Re: Group Short Display by Category In reply to
Do you really need a new category to start with the new table? If you do that, it might mess up a lot of formatting for other subroutines.

I'll need to see your "short" display in order to be able to tell you how to add the category display.


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





Quote Reply
Re: Group Short Display by Category In reply to
Hello Jp,
No, I guess I do not have to start each category with a new table. In fact, what I want is similiar to how this forum displays replies by name. Each new category name can be in a row that spans across the whole table, if that's possible.Here is what I have so far. Most of it is from examples you have posted previously:

&tmp_category(&array_to_hash($_, @hits));

#=========================================================================
$search_url = $ENV{'QUERY_STRING'};
$search_url =~ s/\&sb=\d+//;
$search_url = "$db_script_url?" . $search_url;
print qq|<form METHOD="POST" ACTION="http://dqhppz.cnc.cat.com:8080/cgi-bin/merge.cgi">\n
<center><table bgcolor="#FFFFCC" width=95% border=1 cellpadding=2 cellspacing=0>\n|;
print qq|<tr><td width="1%"><table bgcolor="#CCCCCC" border="0"><tr><td><INPUT TYPE="SUBMIT" VALUE="View"></td></tr></table></td>\n
<td width="65%" valign="bottom"><b><a href="$search_url&sb=0">Group & Description</a></b></td>
<td width="20%" valign="bottom"><b><a href="$search_url&sb=2">Engineer</a></b></td>
<td width="1%" valign="bottom"><b>Rev</b></td>
<td valign="bottom"><b><a href="$search_url&sb=4">Status</a></b></td></tr>|;
# ===========================================================================

for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
if ($tmp{'part'} eq "Yes") {
$tmp{$db_key} =~ s/<?.B>//g;
print qq|<TR><TD align="center" valign="center"><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="$tmp{$db_key}"></TD>|;
}
else {
print qq|<TR><TD align="center" valign="center">None</TD>|;
}
&html_record (%tmp);
print "</tr>";
++$i;
}
if($rec{'Selection'} ne $tmp_category) {
&tmp_category;
}
print "</table></center></form>";
if ($db_next_hits) { print "<br><$font>Pages: $db_next_hits</font>";
}
}
Quote Reply
Re: Group Short Display by Category In reply to
Now I'm really confused! Smile

May I ask what the form tags are for?

Is this for viewing search results?

May I ask what you're using the %tmp hash for?


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





Quote Reply
Re: Group Short Display by Category In reply to
Got it!! I had to put the code down in html_view_success, before my chechbox insertion code. Thanks for getting me going!!