PDA

View Full Version : Using Variables in vBa Template Modules


john2k
05-07-2009, 08:04 PM
I have a variable that I would like to use within a vBa template module. The variable contains HTML (for an advertisement) and I define it within a plugin which is called via the global_start hook.

The variable (for example, $myadhtml) works perfectly fine displaying the appropriate HTML when I put it in the ad_header_logo template but when I put that same exact variable within the template (adv_portal_ads) for my vBa template module no HTML displays in that location on the page.

It's as if variables work in vB's default templates but do not work within vBa templates.

What am I doing wrong?

john2k
05-07-2009, 09:14 PM
I found my answer in another thread:

Admin CP => vBa CMPS => Default Settings => Main Options => Portal Output Global Variables

Try adding 'newposts' (without the quotes or $ sign) to that setting.

All I did was added myadhtml into that section and the variable began working correctly from within the vBa template module.

I'm a bit stumped as to why this worked, though (?). Why was it even necessary to do this?

Our Sponsors
 

Brian
05-08-2009, 10:42 AM
If you have the 'Process PHP File Modules Within A Function' setting enabled in your CMPS then all modules are printed through a function and variables that are set outside of that funciton will need to be globalized in order for them to be available within the function.

john2k
04-16-2010, 08:00 PM
Brian, is there anything you can think of that might cause this same setup to not function correctly in vBa 4.0.0 RC1 or even vB4.0.3?

I recently upgraded one of my sites to both, but am having trouble getting the variable to output the HTML.

Another forum that I publish is still running vB3.8.5 with vBa3.2 and the same setup works perfectly fine.

Our Sponsors
 

john2k
04-21-2010, 03:03 AM
Solution: Turns out that vBulletin 4 handles variables within templates quite a bit differently than in version 3.8.5 & previously.

The "Portal Output Global Variables" setting in vBadvanced seems as though it may now no longer be necessary due to this new vB4 functionality.

Pages with more details on handling variables in vB4:

Referring to plugin variables within your vBulletin 4 templates (http://www.vbulletin.com/forum/entry.php?2385-Referring-to-plugin-variables-within-your-vBulletin-templates)

Pushing your variables to vBulletin 4 templates (http://www.vbulletin.com/forum/entry.php?2387-Pushing-your-variables-to-vBulletin-4-templates)