Achieving that wasn't really that hard. In the old 1.1.X version it was a simple link. However with the new search engine the link wouldn't work anymore.
What I did is went in and look at the "GetNew" function in the search engine. This brings all the new posts for all forums the member can see. Too broad for this application.
So I changed it to:
Code:
// ###################### Start get latest #######################
if ($action=="getlatest") {
// generate query
// do it!
if ($bbuserinfo[userid]!=0 or $bbuserinfo[lastvisit]!=0) {
$forumsql=" AND forumid=$forumid";
// get date:
$datesql=" AND thread.lastpost>=".$bbuserinfo[lastvisit];
$wheresql="1=1".$forumsql.$datesql;
$wheresql.=" AND thread.open<>10";
if ($getsearch=$DB_site->query_first("SELECT searchid FROM search WHERE query='".addslashes($wheresql)."'")) {
$searchid=$getsearch[searchid];
} else {
// get last search for this user and check floodcheck
if ($prevsearch=$DB_site->query_first("SELECT searchid,dateline FROM search WHERE ".iif($bbuserinfo[userid]==0,"ipaddress='$ipaddress'","userid=$bbuserinfo[userid]")." ORDER BY dateline DESC LIMIT 1")) {
if (time()-$prevsearch[dateline]<$searchfloodcheck and $searchfloodcheck!=0) { // and !ismoderator()) {
eval("standarderror(\"".gettemplate("error_pmfloodcheck")."\");");
exit;
}
}
// insert query into db
$DB_site->query("INSERT INTO search (searchid,query,dateline,querystring,showposts,userid,ipaddress) VALUES (NULL,'".addslashes($wheresql)."',".time().",'".addslashes($query)."',0,$bbuserinfo[userid],'".addslashes($ipaddress)."')");
$searchid=$DB_site->insert_id();
}
eval("standardredirect(\"".gettemplate("redirect_search")."\",\"search.php?s=$session[sessionhash]&action=showresults&getnew=true&searchid=$searchid\");");
} else {
$action="getdaily";
}
}
Copy the above code into search.php and you will be able to get the latest posts for a single forum.
wayne, how could i do it to get new posts from a number of forums? I don't mind hard coding it so setting an array in searchphp for say $stargate=3,4,63,23,53,34; and then search.php?group=stargate
I was about to ask for this, Wayne. I saw it on SitePoint and spent a while the other night trying to cobble together my own little version of it and failed miserably.
This function is fabulous and I having working. My question is if you meant to "change" the Get new as you mention on top or just "Copy the above code into search.php" as you mentioned below. I did the second of the two. I didn't change the Get New but added the new code underneath that part of the code. It works, I just wanted to see if having both of the codes in the search.php would cause any problems that you know of.