![]() |
How to pass a variable to template?
Hi everyone,
I'm trying to pass a variable to the template "memberaction_dropdown". I created a new plugin with a hook to postbit_display_start (isn't that where the template is rendered?) with the following code: PHP Code:
{vb:raw memname.appname} It does not work. Then I checked to see if $memname was set using a vb "if" conditional statement and it's not set. Can someone help me by pointing me in the right direction? Thank you very much! |
You need to either add a "global $vbulletin;" line to the start of your code, or else use $this->registry->db instead. Also, if you want the database row you're reading to be for the user who wrote the post, you want to use $post['userid'] instead of $vbulletin->userinfo['userid'].
|
Wow, thanks for the lightning fast response!
Ok, I did this: PHP Code:
<vb:if condition="$memname['app']">Found app!</vb:if> Which doesn't work. I also tried {vb:raw memname.app} which didn't work either. Why is it so hard to pass data to a template :( Edit: postbit_display_start is the correct hook right? |
Oh, sorry about that - it should be $post['userid'] (I fixed it above, for future reference).
|
Great! It works, thank you very much for your help. Enjoy a great holiday season :)
Edit: What would be the correct hook for forumhome_lastpostby? Thanks. I tried forumhome_start, forumdisplay_start, and several others :| Edit 2: Figured it out. There is no correct hook for forumhome_lastpostby, so for those of you scouring the web for it, here's what I did: Search for the text "forumhome_lastpostby" and you'll come across a PHP file with some $templater registering the template. Above that code, put the custom hook, and then you'll be able to pass a variable to forumhome_lastpostby. Hope that helps someone :) |
All times are GMT. The time now is 05:29 AM. |
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:
|