Log in

View Full Version : Which hooks run before postbit is parsed?


SDB
06-17-2007, 02:28 PM
Hi

This is driving me crazy.

I have some serialized data in the datastore. I can get the data out of the database without a problem.

What I can't see to do is reliably get it out and have it available in the postbit template.

In the hook I have the code :

$vbulletin->mydata = unserialize($vbulletin->mydata);

in the postbit template I have the code :

{$vbulletin->mydata['myfield']}

This returns an empty string / nothing in the postbit template.

If i add that code to the footer template, it works fine.

I assume this is because the postbit template is parsed before the hooks I've tried run?

Any help would be really appreciated as to

a) which hooks run before the postbit templates are parsed to build the thread?
b) am I just doing something fundamentally wrong?

Thanks in advance

Simon

Dismounted
06-18-2007, 06:33 AM
postbit_display_start
postbit_display_complete

SDB
06-18-2007, 07:15 AM
hi

Thanks for that, although I presume they run before each and every postbit? If so, I think this would create an unnecessary overhead, unserialising the date before each post.

What hooks run, before any of them are parsed?

Dismounted
06-18-2007, 07:59 AM
showthread_start

SDB
06-18-2007, 08:00 AM
Actually.

Looking into this more, I don't think my problem is trying to find a hook which runs before the postbit template is parsed.. I think my problem is finding one which also happens AFTER the datastore is available?

I've just tried putting my code into postbit_display_start, along with another line :
[quote]$testvar = 1;[/code]

In each post, testvar is populated, but the other data isn't.

Am I just doing something else entirely wrong?

showthread_start

Interestingly, I'm pretty sure that runs after the postbits have been built.

Dismounted
06-18-2007, 11:32 AM
showthread_start is at the top of showthread.php (line 102) :p.

SDB
06-18-2007, 12:58 PM
Hi

Well, whichever way you look at it. If you set a variable's value within the showthread_start it isn't populated when you call it in postbit_legacy.

I've encoutered this problem before.

Dismounted
06-19-2007, 07:24 AM
You will need to globalise the variable at postbit_display_complete/start.
global $vbulletin;

SDB
06-19-2007, 07:43 AM
You are an absolute star!

Thank you very much. :)

I had to stick the $vbulletin->blah into a seperate variable and then globalise that.. but that sorted it.

Thanks a lot.

Simon