Gossamer Forum
Home : Products : DBMan : Customization :

External link to What's New Mod

Quote Reply
External link to What's New Mod
Hey,

I took a look at the What's New Mod. Here's what it says:
"Whichever place you put the code, be sure the following is *not* within a print statement."
But let's say I want to put the link to What's New from a normal html file like:
<a href="http://www.blah.com/cgi-bin/db.cgi&Date-gt=$new&view_records=1">What's New</a>

Then the code "*not* within a print statement" wouldn't be used I think. So... can I just link to the what's new as above from a normal html file?

Eoin
i.am/eoin
Quote Reply
Re: External link to What's New Mod In reply to
No. Sorry. I guess I need to be clearer. The statement needs to be *within DBMan* and not within a print statement.

Your .html page will not be able to fill in the value for the $new variable, so the date will not be sent to the script to search for new records. You'll probably get a message "invalid Date format."


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






Quote Reply
Re: External link to What's New Mod In reply to
So, in other words I can't put an external link to the mod?

Eoin
i.am/eoin
Quote Reply
Re: External link to What's New Mod In reply to
Actually, you can. It takes a little JavaScripting. Here's what you do:

Create a new file, wnew.js, and enter this code:

Code:
<!-- 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 -->

In your external file, add the following code to display the what's new link:

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

This code isn't as accurate as the PERL code, put it does give you a very close resemblance. (It assumes every month has 30 days in it.) You could re-write it to be more accurate per month if you'd like, but this is a quick 'n dirty solution. Smile

Hope this helps!

--Lee
Quote Reply
Re: External link to What's New Mod In reply to
eoin:

I think I found a thread which will provide the solution you are looking for.

As I, and many others, do not enable javascript in their browsers, I like when the solution can be using cgi. Just my personal preference for creating user friendly sites.

More times then not I don't like pointing people to information when they have to read through hostile remarks and rudeness, but the solutions are sometimes within the same thread.

http://www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/002163.html

Hope this helps Smile

Please ask "JPDeni" for additional help if needed.

Quote Reply
Re: External link to What's New Mod In reply to
Very true. While JavaScript can be very helpful, not everyone is able to, or chooses to, utilize it.

It is conceivable that in sub query (db.cgi) near the top, you could have a commandline check:

Code:
if($in{'listnew'}) {

$days = 6; # Number of days for What's New, +1.
$new = &get_date(time() - ($days * 86400));

$in{'Date-gt'} = $new;
}

Then, in your external file, you could reference it by using:

Code:
<A HREF="db.cgi?uid=default&db=default&so=descend&sb=2&listnew=1&view_records=1">What's New</A>

I justed tested this code, and it works like a charm. With this little modification, you could change all "what's new" calls to this format, so you wouldn't have to define $new in every single html display screen. Smile Nothing big, but hey, every little bit.....
--Lee

[This message has been edited by leisurelee (edited April 21, 2000).]

[This message has been edited by leisurelee (edited April 21, 2000).]
Quote Reply
Re: External link to What's New Mod In reply to
Lee's solution is very good. That's the way I would go.

(Off to edit the mod.)


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






Quote Reply
Re: External link to What's New Mod In reply to
Works like a charm!

Thanks

Eoin
i.am/eoin
Quote Reply
Re: External link to What's New Mod In reply to
Thanks, JPD. Glad I could help!

--Lee
Quote Reply
Re: External link to What's New Mod In reply to
Hey,

I've got one more question regarding this topic. I see in the What's New mod there's the following:

Code:
if($in{'listnew'}) {
$days = 6; # Number of days for What's New, +1.
$new = &get_date(time() - ($days * 86400));
$in{'date-gt'} = $new;
$in{'sb'} = 2; # Number of your date field
$in{'so'} = 'descend';
}

I tried changing $in{'so'} = 'descend'; to $in{'so'} = 'ascend'; so that by default the what's new records displayed would be newest at the top. Making the change did not change the order of display (newest at bottom of page).

How by default (not url on a seperate page) can I force the what's new section for newest records at top?

Cheers,
Eoin
i.am/eoin
Quote Reply
Re: External link to What's New Mod In reply to
The key is here:

Code:
$in{'sb'} = 2; # Number of your date field

If the field that contains the Date info is not field 2 (check in your default.cfg to make sure), then change it to the correct field number.

You should also leave $in{'so'} = 'descend';. This will list the results in descending format, the most current being listed first.

Toodles!

--Lee
Quote Reply
Re: External link to What's New Mod In reply to
Hey,

Am I right in saying that I should put

Code:
$in{'sb'} = 12; # Number of your date field

because my default.cfg says:

Code:
'date' => [12, 'date', 12, 255, 1, &get_date(), ''],

I'm asking because changing sb to 12 didn't change the order of the viewed records (oldest first is what's being shown even though $in{'so'} = 'descend'; is specified).

Thanks,
Eoin
i.am/eoin
Quote Reply
Re: External link to What's New Mod In reply to
$in{'sb'} should be equal to the number of your date field.

What's the URL of your database again? I'll take a look.


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






Quote Reply
Re: External link to What's New Mod In reply to
Thanks, the main url is
http://thor.prohosting.com/...cgi-bin/dbman/db.cgi
login with test/test

I put the main files here:
http://thor.prohosting.com/...bman/default_cfg.txt
http://thor.prohosting.com/~eoinc/dbman/db_cgi.txt
http://thor.prohosting.com/...nc/dbman/html_pl.txt
http://thor.prohosting.com/...dbman/default_db.txt

Eoin
i.am/eoin
Quote Reply
Re: External link to What's New Mod In reply to
I see that you have two different codes for "Who's New." On your static page, you have the "listnew=1" type and within DBMan, you have the previous one. They return different results. Do you have the same number of days set?

I can't really tell which (if either) is giving the correct order, since you don't list the date the record was added in your search results.

If you want the results sorted from the link within DBMan, you need to add &sb=12 to the link. In the link on your static page, you don't need &so=descend&sb=2, because those are set in sub query.


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






Quote Reply
Re: External link to What's New Mod In reply to
Yup you were right (of course). I hadn't deleted the old code for the what's new and thought I was pointing to the correct links, but it was still using the old. So, the Who's New is being shown properly now. thanks!

Eoin
i.am/eoin