Gossamer Forum
Home : Products : DBMan : Customization :

combining "what's new" with SSI

Quote Reply
combining "what's new" with SSI
I have the what's new mod installed and it works perfectly. I was just wondering if it would be possible to modify the what's new mod to output its normal stuff but also use it to output the most recently added review (validated) and call that review via SSI to be put on an .shtml page.

Here's what I was thinking of - on my main page, I've been thinking of having something like this:

Latest review:
"username" just reviewed a "field1" "field2"

- clicking latest review will take the user directly to the review.

Is this too far fetched for dbman's capabilities?

Thanks to everyone who has helped me with my dbman thus far... the new site is almost done!


-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: combining "what's new" with SSI In reply to
This thread may be exactly what you are looking for:

Display an individual field

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

Let us know if that helps

Quote Reply
Re: combining "what's new" with SSI In reply to
Yes, his last post is basically what I am looking to do. I only want to put 1 link on there though, not all of the new ones. So it would look for the most recent validated post and it would stay there until a newer one replaces it. I'm expecting a lot of activity on my database so its likely that the link will be changing a lot - which means that I don't really want to set it manually... that's where the date/time thing comes in. I didn't see any date/time stuff in the subs that are in that thread, how would I work that into the whole thing?

Thanks for your input!

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: combining "what's new" with SSI In reply to
The best thing to do when you want to print out the latest record is to use a counter for the key field and do a "List All" with a "descending" sort on the key field. Then just print out the first record that is returned.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: combining "what's new" with SSI In reply to
How would I link to that and only pick out a couple of the fields?

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: combining "what's new" with SSI In reply to
I'll have to get back to you. I have just a couple of minutes before I have to leave and this will take a little longer than that.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: combining "what's new" with SSI In reply to
No problem at all - take your time. Without your help and everyone else who has helped me with my DB, I'd never be able to get it to the point that it is now! The amount of support given on this forum is totally awesome!



-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: combining "what's new" with SSI In reply to
Okay. If I have the SSI part of this correct, you could use just

...db.cg?db=whatever&uid=default&most_recent=1

in your exec or virtual or whatever it is. Smile

In db.cgi, sub main, with all the other elsif statements, add

elsif ($in{'most_recent'}) { &html_most_recent; }

In html.pl, create a new subroutine

Code:

sub html_most_recent {
$in{$db_key} = "*";
$in{'sb'} = the number of your key field;
$in{'so'} = 'descend';

my ($status, @hits) = &query("view");

%rec = &array_to_hash(0,@hits);
$rec{$db_key} =~ s/<\/?B>//g;

print qq|
<a href="$db_script_link_url&$db_key=$rec{$db_key}&ww=1&view_records=1">Latest Review</a>:<BR>
$rec{$db_cols[$auth_user_field]} just reviewed $rec{'Field1'} $rec{'Field2'}
|;
}
Change everything that's in italics above to match your database and that should be it.

The only problem I can think of is if Field1 and Field2 that you want to print out are not in the same database as the review. If not, then it'll take a little more work, but not much.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: combining "what's new" with SSI In reply to
For some reason, it doesn't want to be included on the .shtml page but any other sub that I tack onto the end of the include line works fine. Here's what I have...



Aside from that, the sub that you made works almost 100%. Just a couple glitches.

This is what I put in the html.pl

sub html_most_recent {
$in{$db_key} = "*";
$in{'sb'} = 0;
$in{'so'} = 'descend';
my ($status, @hits) = &query("view");
%rec = &array_to_hash(0,@hits);
$rec{$db_key} =~ s/<\/?B>//g;
print qq|
<a href="$db_script_link_url&$db_key=$rec{$db_key}&ww=1&view_records=1">Latest Review</a>:<BR>$rec{$db_cols[$auth_user_field]} just reviewed a $rec{'Brand'} $rec{'Model'}|;
}

and the output is the following:

Latest Review:
5 just reviewed a 24-Jun-1998 RACEFACE

problem is that the "userid" and "model" aren't correct - "5" should be the "userid" (field 11) and "24-Jun-1998" should be the model (field 7).

The link that is created has "Yes" for the $db_key instead of a number. The $db_key field in my .cfg file is 0 but it looks like its looking at my "Validated" field which is field #12.

Did I do something wrong when I plugged in the new sub into the html.pl?

Once again, thanks for your help! Your amazing!!

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: combining "what's new" with SSI In reply to
I don't think you did anything wrong with the subroutine. It's really odd that the fields are messed up.

Have you got the

db=whatever

set up to point to the correct .cfg file?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: combining "what's new" with SSI In reply to
Even if I call most_recent from another sub - like my header subroutine it does that. I figured Since all that I need to put is &most_recent; in the routine, don't have to put in the db= stuff 'cuz its already in the html.pl for that db.

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: combining "what's new" with SSI In reply to
You do need to tell the script which .cfg file to use.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: combining "what's new" with SSI In reply to
WOA.... I just changed $in{'sb'} = from 0 to 2 and it worked. Strange thing is that 2 isn't the key field, 0 is. Weird stuff... guess its okay now.

Once again thanks for all of your help!!!

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: [JPDeni] combining "what's new" with SSI In reply to
Hello,



I have been trying to implement this thread and am getting a "Internal Server" error - although rest of script runs fine- here is what i have for this:

added working What's New Mod


added in html.pl:

sub html_most_recent {
$in{$db_key} = "*";
$in{'sb'} = 1;
$in{'so'} = 'descend';
my ($status, @hits) = &query("view");
%rec = &array_to_hash(0,@hits);
$rec{$db_key} =~ s/<\/?B>//g;
print qq|
<a href="$db_script_link_url&$db_key=$rec{$db_key}&ww=1&view_records=1">Latest Review</a>:<BR>
just reviewed a $rec{'Type'}|;
}

added in db.cgi:
elsif ($in{'most_recent'}) { &html_most_recent; }

tried the following:
http://www.sundayusa.com/cgi-local/dbman/newleads/db.cgi?db=default&uid=default&most_recent=1&ID=*

Thanks for your help,

Jim

Last edited by:

jogrady: Jun 24, 2002, 12:36 PM