The Arcive of vBulletin Modifications Site. |
|
Details »»
|
|||||||||||||||||||||||||
I am wanting to call up the first post in a thread using the pagetext information in the post table. What would I use as a database query so that I get the pagetext associated with the first post in a thread?
I am wanting to use this in the forumdisplay.php file right before the call to the forumdisplaybit template. I have tried using: $post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid]"); $page=post[pagetext]; But I get varied results and it is is not the first post associated with the threadid. Any ideas? Thanks, Parker Show Your Support
|
|||||||||||||||||||||||||
| Comments |
|
#2
|
||||
|
||||
|
Code:
$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
|
|
#3
|
|||
|
|||
|
Chen:
Thanks. That worked like a champ. Now what would I use to keep the pagetext information limted to the first 30 characters followed by a ....? Is there a code to strip the vbcode and HTML code in the pagetext information? I would prefer to keep the vB code and HTML out of the information that is displayed. Thanks, Parker |
|
#4
|
||||
|
||||
|
Replace:
Code:
$page=$post[pagetext]; Code:
$page=iif(strlen($url)>30,substr($post[pagetext],0,30)."..."),$post[pagetext]); Don't know about the vB code stripping though. |
|
#5
|
|||
|
|||
|
Instead of striping the vBcode would you use the bbcodeparse2 or bbcodeparse?
So you could have: Code:
$page=iif(strlen($url)>30,substr($post[pagetext],0,30)."..."),$post[pagetext]); $page2=bbcodeparse[$page]; or $page2=bbcodeparse2[$page]; Do you think that would work ok? What would you have to use if you wanted to parse the html in the pagetext then? Parker |
|
#6
|
||||
|
||||
|
If you parse vB code, the output will simply have the equal HTML code.
For example, [color=red]text[/color] will be converted to <font color="red">text</font>. Up to you. To convert the text, use this: Code:
$page=bbcodeparse2($page,1,1,1,1); Code:
$page=bbcodeparse2($codetoparse, $html, $imgcode, $smilies, $vbcode); |
|
#7
|
|||
|
|||
|
Chen:
Ok, bare with me a little more. I put in: Code:
$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($url)>30,substr($post[pagetext],0,30)."..."),$post[pagetext]);
$page=bbcodeparse2($page,1,1,1,1);
Then I put in just: Code:
$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($url)>30,substr($post[pagetext],0,30)."..."),$post[pagetext]);
So is $url supposed to be that or something else like $thread[threadid]. I mean where do the $url come from? Also, is the bbcodeparse2 suppsed to have the numbers or the $html, $vbcode, etc.? Thanks again, Parker |
|
#8
|
||||
|
||||
|
Sorry, my bad, use this code:
Code:
$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($post[pagetext])>30,substr($post[pagetext],0,30)."...",$post[pagetext]);
$page=bbcodeparse2($page,1,1,1,1);
And in the bbcodeparse2() call you use 1 or 0 - 1 means it's parsed and 0 means it's not.
|
|
#9
|
|||
|
|||
|
Sorry Chen it is still giving me a parse code error.
In forumdisplay.php I am putting: Code:
$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($post[pagetext])>30,substr($post[pagetext],0,30)."...",$post[pagetext]);
$page=bbcodeparse2($page,1,1,1,1);
Code:
eval("\$forumdisplaybits .= \"".gettemplate('forumdisplaybit')."\";");
}
Also should that be Code:
,30),"...", instead of ,30)."...", ? If I put a right bracket before the eval line I get a parce code error at line 520. Thanks, Parker |
|
#10
|
||||
|
||||
|
This code in forumdisplay.php is working great for me, no errors or anything:
Code:
} else {
$backcolor = '{firstaltcolor}';
$bgclass = "alt1";
}
$post=$DB_site->query_first("SELECT pagetext FROM post WHERE threadid=$thread[threadid] ORDER BY postid");
$page=iif(strlen($post[pagetext])>30,substr($post[pagetext],0,30)."...",$post[pagetext]);
$page=bbcodeparse2($page,1,1,1,1);
eval("\$forumdisplaybits .= \"".gettemplate('forumdisplaybit')."\";");
}
$DB_site->free_result($threads);
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|