PDA

View Full Version : which hook I should use, to take a variable in postbit and SHOWTHREAD


Jhonnyf
10-09-2008, 12:46 PM
I use this php code in showthread_complete hook and work in SHOWTHREAD template

if(stristr($thread[mycustomfield], $vbulletin->userinfo['username']) == TRUE)
{
$userok = TRUE;
}

but I need the result of $userok in postbit template... and when I use a hook like "showpost_post" I can't read $thread[mycustomfield]...

some idea? I need the variable $userdok created using my custom field in thread table.. and that result use to in postbits template..... and I not want to make a SQL sentency for know that field of the table for each postbit

Thank You

Dismounted
10-10-2008, 05:10 AM
showthread_complete is after the postbits have been evaluated. You need to get that data before postbits are evaluated, then in postbit(_legacy), use $GLOBALS[userok].

Jhonnyf
10-10-2008, 10:00 PM
excelent, then I need to use showthread_post_start (yeah, now work) I'm always forget that in postbit I need use $GLOBALS

Thank you

Pure Dope
10-17-2008, 02:00 PM
Is a HOOK the same thing as a EVENT?

Hooks get fired, the same way events get fired?

Lynne
10-17-2008, 02:13 PM
I'm not sure what an Event is. If you look at a vB script, php page, you will see 'hooks' scattered throughout. Those are places you may insert your own php code through the use of plugins. You may want to read up on Products and Plugins in the manual.

Pure Dope
10-17-2008, 02:24 PM
I'm not sure what an Event is. If you look at a vB script, php page, you will see 'hooks' scattered throughout. Those are places you may insert your own php code through the use of plugins. You may want to read up on Products and Plugins in the manual.
well in .NET every time a page load.......events are fired....

like there is a Page_Init event, Page_Load, Page_PreRender, etc...

you can wire up methods to those events....

something like


override protected void OnInit()
{
this.PreRender += new EventHandler(this.Page_PreRender);
}

void Page_PreRender()
{
throw new Exception("Your Method Executed!");
}

So when the page is loading...your function will execute...when that event fires.

Lynne
10-17-2008, 02:52 PM
OK, I guess they are kinda similar. Hooks are page specific, although sometimes the hook is in a page that is run on several pages (like if the hook is in global.php). Like, if you hooked into the hook "member_start" then you are adding code to the beginning of the member.php page, so it only gets executed then. If you hooked into the hook "global_start", then you are adding code to the global.php page which gets executed on nearly every page.

Dismounted
10-18-2008, 10:25 AM
well in .NET every time a page load.......events are fired....

like there is a Page_Init event, Page_Load, Page_PreRender, etc...

you can wire up methods to those events....

something like


override protected void OnInit()
{
this.PreRender += new EventHandler(this.Page_PreRender);
}

void Page_PreRender()
{
throw new Exception("Your Method Executed!");
}

So when the page is loading...your function will execute...when that event fires.
Although hooks are not exactly events, there function similarly. Script execution will reach a defined hook point, and any plugins at that hook will execute.

Jhonnyf
10-18-2008, 10:26 PM
Is a HOOK the same thing as a EVENT?

Hooks get fired, the same way events get fired?
if you look this like a programmer, yes, the hook its like a event beacuse you can add code when something is happening