vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Get new posts within a certain forum, not all- how? (https://vborg.vbsupport.ru/showthread.php?t=9928)

Ryan Little 02-27-2001 01:44 AM

I want to search for new posts within a certain forum, but not within each and every forum.

02-27-2001 01:57 AM

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.

The url to use would be:
http://www.yourforumdomain.com/patht...est&forumid=XX

Where XX equals the forum. I simply stuck this in my "forumhome_forumbit_levelX_post" and "forumdisplay_forumbit_levelX_post" templates.

02-27-2001 02:01 AM

Thanks for the code wayne!

(dev team, is there a reason this isnt standard in v2?)

03-01-2001 07:40 AM

exactly what i need as well :D

03-01-2001 09:59 AM

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

would be fine but i am not quite sure how to.

Is it just a change of

Code:

$forumsql=" AND forumid=$forumid";
or do i need to do more?

03-19-2001 03:38 PM

Any update on this one?

I also need to search more than one forum (but not all) for new posts.

/j

03-19-2001 04:22 PM

I was about to ask for this, Wayne. :D 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.

03-20-2001 02:59 PM

thx for the code. i needed that one

GimmeTech 05-01-2001 06:00 AM

WLuke,

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.

Thank You for sharing your knowledge.

the_sisko 05-01-2001 08:48 PM

How can I protect my private forums???


All times are GMT. The time now is 12:26 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01123 seconds
  • Memory Usage 1,742KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete