Gossamer Forum
Home : Products : DBMan : Customization :

What's New mod problem

Quote Reply
What's New mod problem
JPDeni,

First of all, the support and knowledge you provide this forum is unbelievable! I find it interesting how I read your messages differently, knowing you're not a man. Not quite sure why, but oh well.

Anyway, I tried installing your What's New mod. I got the problematic results you referenced -- the December 31, 1969 query return. I changed things the way you recommended in case that happens, and I still got the 1969 results. Frown Any ideas if there are other ways to change the mod?

One thing I would like to do is modify the search screen so that the date field would be replaced by a drop-down "last day, last 2 days, last week, etc." option along the lines of Discus (I assume you are familiar with this from your message in the Perl/CGI forum). Assuming I can get the "New" mod working, can this be done using sub html_record_form and adding a condition for whether a search is being performed or a record is being added? Or would I need to create a separate sub for the search?

Thanks in advance,
Dan
Quote Reply
Re: What's New mod problem In reply to
Thank you for your nice words. I really do appreciate them.

Quote:
I find it interesting how I read your messages differently, knowing you're not a man. Not quite sure why, but oh well.

Smile

Now to your problem. Can you put your html.pl page where I can see it, in a web directory? I just want to be sure I didn't make a mistake somewhere in the mod.

I tried making one subroutine for all the forms and using "if" statements to tell which things to print out, but it got really confusing. It's really easier to make a new subroutine for the search form. Just be sure you change both html_view_search and html_view_failure to reflect the new subroutine.

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







[This message has been edited by JPDeni (edited May 12, 1999).]
Quote Reply
Re: What's New mod problem In reply to
Thanks for the quick reply. Good news and bad news...

The good news is that your mod works (I never should have doubted you). I had uninstalled it after I first found it to be problematic. I just added it back in so I could post my html.pl for you to look at. Of course, this time your suggested fix worked.

The bad news is that I'm now left scratching my head. Smile Chances are I did something wrong, but I'm quite sure I copied the code in exactly as you wrote it. The only thing I changed was taking out the comments after "$days = 31;" I can't imagine that would have affected anything.

I did notice one small error:

print qq!| <a href="$db_script_link_url&Date-gt=$new&view_records=1>What's New</a> ! if ($per_view);

There should be a quotation mark at the end of the URL. I can still post my html.pl if you want to take a look at it for any reason, but that's probably not necessary at this point.

I'll see if I can figure out the separate search routine with date selections. Keep your fingers crossed that I don't have more questions. Wink

Thanks again,
Dan
Quote Reply
Re: What's New mod problem In reply to
Thank you for pointing out the error. That's the kind of mistake I make a lot. Smile I've fixed it now.

You're "scratching your head" because it didn't work before? Well, you never know what might have happened. Just be thankful it works now. Smile

Regarding the separte search form -- what I have done is to copy the entire html_record_form subroutine and paste it below the old subroutine. Then I rename it to html_search_form and delete the fields I won't be needing. (Much easier than retyping.)

If you need help building the select field, give a holler and I'll be glad to help you out.


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





Quote Reply
Re: What's New mod problem In reply to
Not to worry, I'm quite thankful (and appreciative) that it works. Hey, I copied html_record_form before you recommended it, and I even named it html_search_form! Maybe I'm smarter than I think when it comes to Dbman.

I believe I know how to create the select field. Correct me if I'm wrong. In default.cfg, I now have this:

%db_select_fields = (
Status => 'Individual,Group,Team,Club,Coach,Other',
Seeking => 'General,Training Resource,Seeking Coaching,Looking for a Training Group,Training Group Looking for Members',
NewDate => '1,2,3,7,14,31,365'
);

with NewDate being the addition. Then in html.pl under html_search_form I change the date section to:

<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Within Last (days):</FONT></TD>
<TD VALIGN="TOP"> |; print &build_select_field ("NewDate", "$rec{'NewDate'}"); print qq|</TD></TR>


How do I then get the Date select box to point to the right section in db.cgi? The link that you created for it is:

<A HREF="$db_script_link_url&Date-gt=$new&view_records=1">New</A>

Can I get the standard search submit to accept this value? Also, where should I move this section to?

$days = 31; # set this one day more than you want records to be considered "new."
# If you want to include records from the previous 7 days, set the number
# to 8.

$time = time() - ($days * 86400);

my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;

$new = "$day-$months[$mon]-$year";


Would it go in html_search_form or within html_view_search which calls the form? Of course, I will need to set $days to the value selected in the search drop-down (NewDate). I imagine this would affect the placement of the code above.

I sure hope all that code formats itself in a legible manner...

Dan

[This message has been edited by Dan Kaplan (edited May 12, 1999).]
Quote Reply
Re: What's New mod problem In reply to
You're going to have to build your select field yourself, instead of having DBMan do it for you.

Go to your html_search_form (great minds! Smile ) and instead of

print &build_select_field ("NewDate", "$rec{'NewDate'}");print qq|</TD></TR>


use this code:

Code:
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;

my (@number_of_days) = qw!2 3 4 8 15 32 366!;
$daytext[2] = "last day";
$daytext[3] = "last two days";
$daytext[4] = "last three days";
$daytext[5] = "last two weeks";
$daytext[6] = "last month";
$daytext[366] = "last year";

# Note that each of the numbers is one day more than indicated by the text.

print qq|<SELECT NAME="PostDate-gt"><OPTION VALUE ="">---|;

foreach $days (@number_of_days) {
$time = time() - ($days * 86400);
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
($day < 10) and ($day = "0$day");
$year = $year + 1900;
print qq|<OPTION VALUE="$day-$months[$mon]-$year">$daytext[$days]|;
}
print "</SELECT>";
print qq|</TD></TR>

I think your field is called "PostDate." If not, change the field in bold above.

I haven't tested this, but I don't think there are any syntax errors in it. (I hope not! Smile ) Give 'er a shot and see what happens.


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







[This message has been edited by JPDeni (edited May 12, 1999).]
Quote Reply
Re: What's New mod problem In reply to
You're awesome! It works beautifully. Furthermore, you answered at least four questions all with one fell swoop. Smile

I made a couple small changes to the code you wrote:

<TD VALIGN="TOP"> |;
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
my (@number_of_days) = qw!2 3 4 8 15 32 366!;
$daytext[2] = "last day";
$daytext[3] = "last two days";
$daytext[4] = "last three days";
$daytext[8] = "last week";
$daytext[15] = "last two weeks";
$daytext[32] = "last month";
$daytext[366] = "last year";
# Note that each of the numbers is one day more than indicated by the text.
print qq|<SELECT NAME="Date-gt"><OPTION VALUE ="">---|;
foreach $days (@number_of_days) {
$time = time() - ($days * 86400);
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
($day < 10) and ($day = "0$day");
$year = $year + 1900;
print qq|<OPTION VALUE="$day-$months[$mon]-$year">$daytext[$days]|;
}
print "</SELECT>";
print qq|</TD></TR>


My field name is "Date-gt." Also, I changed the $daytext[] numbers and included the one week option -- not too important to you (unless you decide to make it an official mod; hint, hint), but just in case anyone else is following along...

Thanks for answering all my questions so quickly and for teaching me a bit more about Dbman in the process.

Dan

p.s. If you'd like to check out the "finished" product, here's the URL:

http://www.dankaplan.com/cgi-bin/dbman/db.cgi
Quote Reply
Re: What's New mod problem In reply to
Way cool! Not only that it works (which it does very nicely), but even more that you were able to get it to do what you wanted it to by following the patterns. That's the best result I could hope for.

I suppose I'll come back and pick up the code to make an "official" mod when someone else asks for something similar. Smile

I'm sure glad it worked for you.


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