![]() |
Help with call to database in postbit hook
I am trying to get a total of posts from the post table so that I can include that in my postbit template.
I have tried using the following in the postbit_start hook. Code:
$postcount=$db->query_first("SELECT COUNT(*) AS posts FROM post WHERE postid AND post.visible=1"); Any ideas how to make this work? Thanks, Parker |
Quote:
|
Quote:
Are you sure you want to run that query on every postbit? Best would be to run the query say at the start of the page (e.g. showthread_start) and then use the variable in the postbit. (Note: You may need to use the $_GLOBALS['postcount']['posts'] variable to access the data) |
$thread[replycount] or $threadinfo[replycount]
One of those works, I can't remember which offhand. You don't need to run any queries. |
Hang on...what postcount are you trying to get? The total forum postcount or the postcount for the thread?
Your SQL doesn't make much sense. [sql]SELECT COUNT(*) AS posts FROM post WHERE postid AND post.visible=1[/sql] :confused: If its the number of replies to the thread then the above post is correct. |
Quote:
--------------- Added [DATE]1196622101[/DATE] at [TIME]1196622101[/TIME] --------------- Quote:
|
It is to get the number of replies in a thread. Let say you have a thread with 10 total posts. I want to post the $totalpost count in that thread so it will say Post 1 of 10 or 5 of 10, etc.
Thanks, Parker |
$thread[replycount] then :) No queries necessary
|
Dean:
Thanks. To make the count correct though I created a hook in postbit_display_start and used $postcount=$thread[replycount]+1; Otherwise if there are 15 posts the 15th post shows up as Post 14 of 15. Thanks again. |
Better than running a query for every post though ;)
|
All times are GMT. The time now is 06:02 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|