The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Assistance with simple plugin - variable registering
This should be so simple and I seem to get this every time.
I am trying to execute a query at global_start (or anywhere that's available to the header template). I know the query works as in the code below I echo out the result and it works. What I can't do, is get the result output into the header template! I know about registering variables, I've had that work before but once again despite numerous permutations this simply won't work. I have even now tried using a non-existent template hook and then added that template hook into the header template - a trick I have used before to avoid the registering nonsense - but STILL it won't output. Having tried about 436 different combinations of code, I'm now at a loss...can anyone tell me where I am going wrong? I can echo $template_hook['status'] and it outputs correctly, but putting {vb:raw template_hook.status} into the template does nothing. Code:
$userid = $vbulletin->userinfo['userid']; $sql2 = "SELECT * FROM `dbtech_status_statuslog` ORDER BY `dbtech_status_statuslog`.`statuslogid` DESC LIMIT 1"; $query = mysql_query($sql2); if(!$query) { echo 'Query failed'; } else { echo 'Query Ok'; } $data = mysql_fetch_assoc($query); $template_hook['status'] = $data['status']; echo $template_hook['status']; |
#2
|
|||
|
|||
Just for an experiment, try decreasing the execution order of your plugin. Or else try using hook parse_templates instead.
|
#3
|
|||
|
|||
Thanks, that was it...needs to be parse_templates. never quite understand why that has to be the case, since I guess that's not what that hook was designed for.
|
#4
|
|||
|
|||
I don't know - I think the hooks are named more for where they are in the code than what you're 'supposed' to do with them (although sometimes it's the same thing). parse_templates is just before the header is rendered (as well as some other common templates) so I think it's a good place to register extra variables.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|