vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Pulling thread title from query (https://vborg.vbsupport.ru/showthread.php?t=49743)

Boofo 03-07-2003 03:05 AM

Pulling thread title from query
 
What I'm trying to do with the code below is pull both the post title (if there is one) and the thread title from the getlastposts query. What I want it to do is is show "Re: threadtitle" is there is no post title. Can someone please tell me what I am doing wrong?

PHP Code:

$totalposts=$userinfo[posts];
  if (
$totalposts!=or $userinfo[lastpost]!=0) {
    
$getlastposts=$DB_site->query("SELECT thread.title,thread.threadid,thread.forumid,post.title,postid,post.dateline FROM post,thread WHERE thread.threadid=post.threadid AND post.userid=$userinfo[userid] AND post.visible=1 ORDER BY post.dateline DESC");
    
$postctr=0;
    
$latestposts="";
    while (
$getlastpost=$DB_site->fetch_array($getlastposts)) {
      
$getperms=getpermissions($getlastpost[forumid],$bbuserinfo[userid],$bbuserinfo[usergroupid]);
      if (
$getperms[canview]==1) {
        
$postdate=vbdate($dateformat,$getlastpost[dateline]);
        
$posttime=vbdate($timeformat,$getlastpost[dateline]);
        
$posttitle=$getlastpost[title];
        
$posttitle=censortext($posttitle);
        
$posttitle=htmlspecialchars($posttitle);
        
$posttitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $posttitle);
        
$threadtitle=$getlastpost[title];
        
$threadtitle=censortext($threadtitle);
        
$threadtitle=htmlspecialchars($threadtitle);
        
$threadtitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $threadtitle);
        
$posturl="showthread.php?postid=$getlastpost[postid]#post$getlastpost[postid]";
        
$postctr++;
        if (
$postctr==1){
          
$lastpostdate=$postdate;
          
$lastposttime=$posttime;
          
$lastposttitle=$posttitle;
          
$lastposturl=$posturl;
        }
        eval(
"\$latestposts .= \"".gettemplate("getinfo_latestposts")."\";"); 


mr e 03-07-2003 04:17 AM

then you'd do something like this

PHP Code:

$totalposts=$userinfo[posts];
  if (
$totalposts!=or $userinfo[lastpost]!=0) {
    
$getlastposts=$DB_site->query("SELECT thread.title,thread.threadid,thread.forumid,post.title,postid,post.dateline FROM post,thread WHERE thread.threadid=post.threadid AND post.userid=$userinfo[userid] AND post.visible=1 ORDER BY post.dateline DESC");
    
$postctr=0;
    
$latestposts="";
    while (
$getlastpost=$DB_site->fetch_array($getlastposts)) {
      
$getperms=getpermissions($getlastpost[forumid],$bbuserinfo[userid],$bbuserinfo[usergroupid]);
      if (
$getperms[canview]==1) {
        
$postdate=vbdate($dateformat,$getlastpost[dateline]);
        
$posttime=vbdate($timeformat,$getlastpost[dateline]);
        
$posttitle=$getlastpost[title];
        
$posttitle=censortext($posttitle);
        
$posttitle=htmlspecialchars($posttitle);
        
$posttitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $posttitle);
        
$threadtitle=$getlastpost[title];
        
$threadtitle=censortext($threadtitle);
        
$threadtitle=htmlspecialchars($threadtitle);
        
$threadtitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $threadtitle);
        
$posturl="showthread.php?postid=$getlastpost[postid]#post$getlastpost[postid]";

if (
$posttitle == "") { //only part i changed
$posttitle "Re: $threadtitle";//
}//

        
$postctr++;
        if (
$postctr==1){
          
$lastpostdate=$postdate;
          
$lastposttime=$posttime;
          
$lastposttitle=$posttitle;
          
$lastposturl=$posturl;
        }
        eval(
"\$latestposts .= \"".gettemplate
("getinfo_latestposts")."\";"); 


Boofo 03-07-2003 04:22 AM

Here's what i want to do. I want it to loist like this:

posttitle (Thread: threadtitle)

Will this do this? And how can I get the actual number of posts if a user has less than 10 posts?

mr e 03-07-2003 04:25 AM

loist?

anyways, so if there is no post title you want the post title to be "Re: $threadtitle" where $threadtitle is the title of the thread?

Boofo 03-07-2003 04:25 AM

Here's the code I am working with now. I took out all the other stuff because it wasn't working.

PHP Code:

  $totalposts=$userinfo[posts];
  if (
$totalposts!=or $userinfo[lastpost]!=0) {
    
$getlastposts=$DB_site->query("SELECT thread.title,thread.threadid,thread.forumid,postid,post.dateline FROM post,thread WHERE thread.threadid=post.threadid AND post.userid=$userinfo[userid] AND post.visible=1 ORDER BY post.dateline DESC");
    
$postctr=0;
    
$latestposts="";
    while (
$getlastpost=$DB_site->fetch_array($getlastposts)) {
      
$getperms=getpermissions($getlastpost[forumid],$bbuserinfo[userid],$bbuserinfo[usergroupid]);
      if (
$getperms[canview]==1) {
        
$postdate=vbdate($dateformat,$getlastpost[dateline]);
        
$posttime=vbdate($timeformat,$getlastpost[dateline]);
        
$posttitle=$getlastpost[title];
        
$posttitle=censortext($posttitle);
        
$posttitle=htmlspecialchars($posttitle);
        
$posttitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $posttitle);
        
$posturl="showthread.php?postid=$getlastpost[postid]#post$getlastpost[postid]";

if (
$posttitle == "") { //only part i changed
$posttitle "Re: $threadtitle";//
}//

        
$postctr++;
        if (
$postctr==1){
          
$lastpostdate=$postdate;
          
$lastposttime=$posttime;
          
$lastposttitle=$posttitle;
          
$lastposturl=$posturl;
        }
        eval(
"\$latestposts .= \"".gettemplate("getinfo_latestposts")."\";");
        if (
$postctr==$showposts) {
         break;
        }
      }
    }
  } else {
  eval(
"\$latestposts .= \"".gettemplate("getinfo_latestpostsnone")."\";"); 


Boofo 03-07-2003 04:27 AM

Quote:

Originally posted by mr e
loist?

anyways, so if there is no post title you want the post title to be "Re: $threadtitle" where $threadtitle is the title of the thread?

Yes, sir. I want to have the thtreadtitle after it on all of them, too. I thought I had it once but I got messed up somewhere. ;)

mr e 03-07-2003 04:29 AM

well i look at the query and you aren't getting the post title, you have thread.title so your $posttitle=$getlastpost[title] is really your thread title

is this out of a php file or did you modify it?

Boofo 03-07-2003 04:30 AM

Quote:

Originally posted by mr e
loist?


loist=look

LOL My damned keyboard can't spell.

mr e 03-07-2003 04:30 AM

so you want the post's title AND the thread's title?

Boofo 03-07-2003 04:31 AM

Quote:

Originally posted by mr e
well i look at the query and you aren't getting the post title, you have thread.title so your $posttitle=$getlastpost[title] is really your thread title

is this out of a php file or did you modify it?

It's from an older hack I am updating for my site. How do we get the post title out of that query?

Boofo 03-07-2003 04:33 AM

Quote:

Originally posted by mr e
so you want the post's title AND the thread's title?
LOL We keep cross-posting here.

Yes, I want to get them both. :)

mr e 03-07-2003 04:40 AM

LOL, ya we are cross posting

ok try this, it's late so it might not be perfect and if it's not i'll fix it tomorrow cuz my bed's calling me :)

PHP Code:

$totalposts=$userinfo[posts];
  if (
$totalposts!=or $userinfo[lastpost]!=0) {
    
$getlastposts=$DB_site->query("SELECT thread.title AS threadtitle,thread.threadid,thread.forumid,post.title AS posttitle,post.postid,post.dateline,post.userid,post.visible FROM thread,post WHERE thread.threadid=post.threadid AND post.userid=$userinfo[userid] AND post.visible=1 ORDER BY post.dateline DESC");
    
$postctr=0;
    
$latestposts="";
    while (
$getlastpost=$DB_site->fetch_array($getlastposts)) {
      
$getperms=getpermissions($getlastpost[forumid],$bbuserinfo[userid],$bbuserinfo[usergroupid]);
      if (
$getperms[canview]==1) {
        
$postdate=vbdate($dateformat,$getlastpost[dateline]);
        
$posttime=vbdate($timeformat,$getlastpost[dateline]);

        
$posttitle=$getlastpost[posttitle]."(Thread: ".$threadtitle.")";
        
$posttitle=censortext($posttitle);
        
$posttitle=htmlspecialchars($posttitle);
        
$posttitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $posttitle);
        
$posturl="showthread.php?postid=$getlastpost[postid]#post$getlastpost[postid]"///////// <- Not sure what this is supposed to be, what's with the # sign?

        
$postctr++;
        if (
$postctr==1){
          
$lastpostdate=$postdate;
          
$lastposttime=$posttime;
          
$lastposttitle=$posttitle;
          
$lastposturl=$posturl;
        }
        eval(
"\$latestposts .= \"".gettemplate("getinfo_latestposts")."\";");
        if (
$postctr==$showposts) {
         break;
        }
      }
    }
  } else {
  eval(
"\$latestposts .= \"".gettemplate("getinfo_latestpostsnone")."\";"); 


Boofo 03-07-2003 06:56 AM

Thank you, sir. Works great. With just a few tweaks I got it running smooth. I owe you one. ;)

mr e 03-07-2003 02:39 PM

oh cool :D i guess i can code when im asleep ;)

Falkware 05-10-2003 10:06 PM

How do you then get this into postbit template to display the RE: threadtitle on all replies after the initial threadpost? I've been looking for something like this as well to avoid an empty field in my postbit.

Boofo 05-10-2003 10:14 PM

In newreply.php, find:

PHP Code:

// ############################### start post reply ###############################
if ($HTTP_POST_VARS['action']=="postreply") {

  
// check for subject and message
  
$message=trim($message);
  if (
$message=="") {
    eval(
"standarderror(\"".gettemplate("error_nosubject")."\");");
    exit;
  } 

BELOW it add:

PHP Code:

    if ($postinfo[title]!="") {
    
$title="Re: ".htmlspecialchars($postinfo[title]);
    }
    
$title str_replace("Re: Re: ""Re: "$title); 

Still in newreply.php, find:

PHP Code:

    $title=censortext($title);
    
$message=censortext($message); 

ABOVE it add:

PHP Code:

    if ($title=="") {
    
$title="Re: ".$thread[title];
    } else {
    
$title=$title;
    }
    
$title str_replace("Re: Re: ""Re: "$title); 

If you have the multiple quotes hack installed, there is a couple more places you will need it, too. Let me know if you need that also.

Falkware 05-22-2003 12:28 AM

Thank you..got it working now. Also made it put it in using the quick reply box.

Appreciate the help.

Boofo 05-22-2003 09:54 AM

Quote:

Yesterday at 08:28 PM Falkware said this in Post #17
Thank you..got it working now. Also made it put it in using the quick reply box.

Appreciate the help.

How did you do that?


All times are GMT. The time now is 05:02 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.02194 seconds
  • Memory Usage 1,863KB
  • 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
  • (8)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete