PDA

View Full Version : Querying Postbit Hook


paul41598
05-01-2009, 12:56 PM
I'm having some issues pulling this off. Its fruturating. Any suggestions?

In postbit_display_start hook

global $db, $vbulletin;

$getthread = $vbulletin->db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "thread
WHERE threadid = '". $threadinfo['threadid']."'
");

while ($getthread1 = $vbulletin->db->fetch_array($getthread))
{

eval('$display .= "' . fetch_template('test') . '";');
}


In postbit_legacy template I have this:

$display


In "test" template I have:

$getthread1[title]


Nothing is showing, and I have no idea why

bananalive
05-01-2009, 01:37 PM
global $threadinfo; as well needed for $threadinfo['threadid']

or use $post[threadid] instead

Lynne
05-01-2009, 02:30 PM
I think bananalive is correct, try $post instead of $threadinfo.

paul41598
05-01-2009, 02:43 PM
THanks guys, think we're good. One other thing.

What If I wanted the $display variable to only show on the first thread/post (thread starter). RIght now its showing on every single post under it...

Whats the suggestion there?

Lynne
05-01-2009, 03:15 PM
Maybe:
<if condition="$post['postid']==$thread['firstpostid']">
$display
</if>

paul41598
05-01-2009, 03:40 PM
I havnt tried that yet, I will. Now I have one last issue. I'm trying to display the same thing on forumdisplay. My forumdisplay query hook has:

$hook_query_fields .= ", thread_expiry";

if I put $thread[thread_expiry] in my threadbit template...Im able to pull my timestamp results just fine, but they are in unix time.

So beneath it I'm trying to do:
$thread['thread_expiry'] = vbdate($vbulletin->options['dateformat'], , $thread['thread_expiry']);

It's not converting it though. Is this right or do I need it in another hook? I tried putting that conversion code part in forumdisplay start hook too and no luck...it doesnt convert it

Lynne
05-01-2009, 03:52 PM
What's with the extra comma in there?

You didn't say which hook location you are using for converting the date. That is the way you would get the date (but not the time).

paul41598
05-01-2009, 03:57 PM
No reason for the comma..oops. For converting the data, I'm using the same hook. forumdisplay_query

$hook_query_fields .= ", thread_expiry";
$thread['thread_expiry'] = vbdate($vbulletin->options['dateformat'], , $thread['thread_expiry']);

That didn't work so I left the $hook_query line of code in the forumdisplay_query hook

then i tried putting

$thread['thread_expiry'] = vbdate($vbulletin->options['dateformat'], , $thread['thread_expiry']);

inside of forumdisplay_start hook and I tried forumdisplay_complete.

Lynne
05-01-2009, 04:17 PM
The query hook adds fields to the query that is right after it in the code. So, the field isn't available until after the query. Go find that hook in the code and then see what hook you can use after the field is available to do something to the date (threadbit_display?).

paul41598
05-01-2009, 05:09 PM
Lynne! Thank you!

You were right, threadbit_display was the right hook to call. It now works! Thank you so much for your help