Gossamer Forum
Home : Products : DBMan : Customization :

What's New Mod Error

Quote Reply
What's New Mod Error
 
I'm having troubles with the What's New mod. When I try the link, I get this message:

Invalid date format: '$new'

I read through a thread addressing this that mentioned having -'s and spaces
in the date format, but I *think* I'm being consistent. I'm not very good
at Perl, and it's been 7 months since I originally customized this script,
so I'm having trouble getting back into it. It seems to log the date just
fine, but I can't get it to pull up the new items. Help? Smile Posting parts
of my code below:


Sample data records:
2186|SBP12-5838|Pink Roses|acid free, lignin free, 12 x 12|Paper_12x12|Small_Craft_Punches|.30|sbp12-5838.gif|sbp12-5838t.gif| || || || || || ||31-Mar-2000
2187|SBP12-5839|Blue Stars|acid free, lignin free, 12 x 12|Paper_12x12|SonBurn|.30|sbp12-5839.gif|sbp12-5839t.gif| || || || || || ||31-Mar-2000

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

This is the structure of the Date field:
Date => [21, 'date', -1, 15, 1, &get_date, ''],

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

sub get_date {

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

return "$day-$months[$mon]-$year";
}

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

sub date_to_unix {

my ($date) = $_[0];
my (%months) = ("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4, "Jun" => 5,
"Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9, "Nov" => 10,"Dec" => 11);
my ($time);
my ($day, $mon, $year) = split(/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }

use Time::Local;
eval {
$day = int($day); $year = int($year) - 1900;
$time = timelocal(0,0,0,$day, $months{$mon}, $year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}

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

##########################################################
## What's New Mod ##
##########################################################
# Put any globals you like in here for your html pages.

$days = 15; # 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.

$new = &get_date(time() - ($days * 86400));
$new = "$day-$months[$mon]-$year";

...thanks in advance!

-Joyce
Quote Reply
Re: What's New Mod Error In reply to
Where are linking the What's New? You cannot link this in an external web page. You have to use the following link within the sub-routine where you have defined $new, like the following:

Code:
<a href="$db_script_link_url&Date-gt=
$new&view_records=1&$db_key=*&sb=1&so=descend">

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: What's New Mod Error In reply to
Well... yuck. I was using the same thing you posted, but as a hard-link search from an outside page (with http://address-of-script in place of $db_script_link_url).

Is that not possible at all? It seems to *try* to do it, as I do get the error message about the date format not being correct? Sure would be helpful to have an outside link directly into what's new!

Thanks,
Joyce
Quote Reply
Re: What's New Mod Error In reply to
Hard linking outside of the DBMAN script will not work. The only other answer is using SSI. I did post codes for another user to use SSI of the New Records in an external web page.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: What's New Mod Error In reply to
You might try the mod "Newest Records" instead of "What's New." The mod is at http://www.jpdeni.com/...n/Mods/newrecord.txt .

With that, you will be able to set up a link on a static html page to list the newest x number of records in your database. The structure of the link (after you install the mod) would be

Code:
...db.cgi?db=default&uid=default&new_records=1

Is this more like what you want?


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






Quote Reply
Re: What's New Mod Error In reply to
 
Quote:
Hard linking outside of the DBMAN script will not work. The only other answer is using SSI. I did post codes for another user
to use SSI of the New Records in an external web page.

Actually, it is possible to link from an external file. It's quite simple, actually. Just takes a little javascript. This code is not going to give you the exact same results as the PERL code for it, but it will allow you to put the link in an external file.

Create a file, called wnew.js, with the following code:
Quote:
<!-- Begin
m = new Array(
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
);

today = new Date();
day = today.getDate();
year= today.getYear();
month= today.getMonth();
day=day-5;

if(day<=0) {
day=day+30;
month=month-1;
}

if(month<=0) {
month=12;
year=year-1;
}

document.write("<A HREF=http://path/to/db.cgi?db=default&uid=default&Date-gt="+day+"-"+m[month]+"-");
if (today.getYear() >=1900) {
document.write(year);
}
else {
document.write((1900+year));
}
document.write("&sb=2&so=descend&view_records=1>What's New</A>");
// End -->

Then, in your external HTML file, place the following code where you want the What's New link to be:

Quote:
<SCRIPT LANGUAGE="JavaScript" SRC="wnew.js"></SCRIPT>

Change day=day-5; in the wnew.js file to whatever your number of days to show is. For example, to show the last month, you'd put day=day-30.

Let me know if there's any questions! Smile



------------------
----------------------------------------
Lee Leisure
HP Customer Relations Manager
----------------------------------------
* NOTE: This message is intended
for personal purposes only, and does
not imply the position or opinion of
the Hewlett Packard Company.