Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 17 Dec 2009, 04:11
vaskies vaskies is offline
 
Join Date: Dec 2009
Lightbulb RESOLVED: Calling a Variable from Plugin in VB4

I'm trying to call a variable from a plugin in a stock template. Is it necessary I render the variable in its own custom template first, then call it inside the stock template using {vb:raw $mytemplate}? I thought this seemed superfluous and wanted to be sure as I just finished reading over http://www.vbulletin.org/forum/showthread.php?t=228078 .

Last edited by vaskies; 17 Dec 2009 at 17:24.
Reply With Quote
  #2  
Old 17 Dec 2009, 04:37
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
You may call a varialbe in a stock template, however you much register it for use in that template first. If it's a stock template, then you may have to preregister it if you aren't going to use a template_hook or a variable array that is already registered.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #3  
Old 17 Dec 2009, 05:53
vaskies vaskies is offline
 
Join Date: Dec 2009
I pre-register the variables I'm using in the stock template inside the plugin itself, correct? For instance, I have an array named $array that I'm trying to use in the FORUMHOME template.

In the plugin:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

In FORUMHOME template:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Nothing outputs, though.

Last edited by vaskies; 17 Dec 2009 at 06:04.
Reply With Quote
  #4  
Old 17 Dec 2009, 06:10
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
I am pretty sure that $array is a reserved word and you may not use it as a variable name.

And then I think you want to do something more along this line:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then you may use {vb:raw var1} and {vb:raw var2} in the template.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #5  
Old 17 Dec 2009, 07:34
consolegaming consolegaming is offline
 
Join Date: Jan 2007
And the plugin needs to be assigned to the parse_templates hook I believe or at least the global hook wouldn't work for me.
Reply With Quote
  #6  
Old 17 Dec 2009, 07:52
vaskies vaskies is offline
 
Join Date: Dec 2009
Originally Posted by Lynne View Post
I am pretty sure that $array is a reserved word and you may not use it as a variable name.

And then I think you want to do something more along this line:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then you may use {vb:raw var1} and {vb:raw var2} in the template.
Ah, thank you. I was unaware keys were necessary. I'm new to PHP and never have had the occasion to use a key value pair. Good to know! Also, $array works as a variable. Bad practice though.

Originally Posted by consolegaming View Post
And the plugin needs to be assigned to the parse_templates hook I believe or at least the global hook wouldn't work for me.
Hm. I'm using the forumhome_start hook which is working fine for me. I'll keep that in mind though if/when I make a plugin that needs to be used on more than one template. Thanks
Reply With Quote
  #7  
Old 17 Dec 2009, 16:20
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Actually you may be fine with just registering variables but I do know that when I was trying to register a custom template it wouldn't work with the global hook and I read someone's post (I think it was Lynne's) suggesting to someone else to use the parse_templates.

As long as it works for you it doesn't make a difference lol.

EDIT: BTW can someone move my thread from the design froum to this one. Realized after I posted it that it should have been here.

Last edited by consolegaming; 17 Dec 2009 at 17:04.
Reply With Quote
  #8  
Old 17 Dec 2009, 18:01
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Originally Posted by consolegaming View Post
EDIT: BTW can someone move my thread from the design froum to this one. Realized after I posted it that it should have been here.
Hit the Report this Post button and ask to have it moved to the xxx forum.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 03:57.

Layout Options | Width: Wide Color: