The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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! |
#2
|
|||
|
|||
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'].
|
#3
|
|||
|
|||
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? |
#4
|
|||
|
|||
Oh, sorry about that - it should be $post['userid'] (I fixed it above, for future reference).
|
#5
|
|||
|
|||
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 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|