Gossamer Forum
Home : Products : DBMan : Customization :

Colorizing Spreadsheet Mod

Quote Reply
Colorizing Spreadsheet Mod
I saw in the various threads how to alternate the colors of the spreadsheet mod.

Question: How do
I color the header row using a variable in the cfg file instead of hard coding the html.pl file?

Here is the code for coloring via hard codeing html.pl

Code:
# Note: In each of the header cells, replace # with the field number
# of the field that is associated with that header -- in both places within each line.
print qq|
<TABLE border="1"><TR bgcolor="#00CC00"><TD><a href="$db_script_url?$new_url&sb=1&so=$so[1]">Products</a></TD>
<TD><a href="$db_script_url?$new_url&sb=2&so=$so[2]">Manufacturer</a></TD>
<TD><a href="$db_script_url?$new_url&sb=3&so=$so[3]">Website</a></TD></TR>\n|; for (0 .. $numhits - 1) {
$color = !$color;
print qq|<tr bgcolor="$row_color[$color]">|;
&html_record (&array_to_hash($_, @hits));
print "</tr>";
++$rec_count;
}



I have setup a variable in the default.cfg file like this,
Code:
# ===========================================================================
# Spreadsheet Mod Alternate Row Color change settings
$row_color[0] = '#FFFFFF';
$row_color[1] = '#009000';
$row_color_header = '00CC00';



I added this
Code:
<TABLE border="1"><TR bgcolor="$row_color"><TD><a href="$db_script_url?$new_url&sb=1&so=$so[1]">Products</a></TD>
<TD><a href="$db_script_url?$new_url&sb=2&so=$so[2]">Manufacturer</a></TD>
<TD><a href="$db_script_url?$new_url&sb=3&so=$so[3]">Website</a></TD></TR>\n|;


But it didn't work. What am I missing?

Ed

Last edited by:

ewramos: Jul 24, 2006, 6:49 AM
Quote Reply
Re: [ewramos] Colorizing Spreadsheet Mod In reply to
Your variable names don't match. It should be

Code:
<TABLE border="1"><TR bgcolor="$row_color_header"><TD><a href="$db_script_url?$new_url&sb=1&so=$so[1]">Products</a></TD>
<TD><a href="$db_script_url?$new_url&sb=2&so=$so[2]">Manufacturer</a></TD>
<TD><a href="$db_script_url?$new_url&sb=3&so=$so[3]">Website</a></TD></TR>\n|;


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Colorizing Spreadsheet Mod In reply to
2 errors that snowballed on me...

1. I mistyped the code in the original post for the table display.

2. I left out the '#' symbol in the default.cfg file.

Your suggestion prompted me to troubleshoot in more detail, thanks for the help.

I'm not a perl programmer just a cut & past guy so my questions are no doubt 'simple'. Again thanks for the help.

Ed 8-)

Here is a link to the proto type pages for a customer. When he approves a 'style' I will definitly purchase dbman. What a lifesaver app for simple needs I have.

http://www.edward-ramos.net/...ds=1&Record_ID=*

http://www.edward-ramos.net/...ds=1&Record_ID=*


I am thinking of adding a MFG logo image field for the second version to display each MFG logo. Just a thought now though.

Last edited by:

ewramos: Jul 24, 2006, 8:47 AM
Quote Reply
Re: [ewramos] Colorizing Spreadsheet Mod In reply to
It's no problem at all. We all have to start some place. I still do a lot of copy and paste when I know that the code I want is already written. No point in retyping and risking an error. I can't tell you how many 500 Errors I get because I've done something like leave off a semi-colon. :-)

I'm really glad that you've been able to find something you can use. DBMan is a lovely program -- which I can say because I didn't write it. LOL. I just happened on it, much like you did, without any knowledge of Perl at all. Working with DBMan is what taught me.

An extra little plug for Alex... I've come across other Perl programs that I've tried to edit, but they were poorly-written and had few or no comments so it was impossible to figure out what and where to edit it to make it do the tricks I wanted to do. I didn't realize how lucky I was to come across DBMan as my first foray into Perl. Otherwise, I might have given up completely.


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