![]() |
Exporting variable from plugin to template
Hi,
I need just to make available a new variable in my template. If the requested url contains a custom value (a referral index), I need to add this value to profiles url. I'm new to vbulletin programming; I need to do something like: Code:
if ($_GET['fref']=='PS') $_SESSION['fref']='PS'; |
Where do you want the variable available for use?
|
I need the variable in template because I need to replace profile and user links (I need to integrate with drupal user base).
Thanks |
I was trying to ask - which template?
|
Sorry,
not template... style :) I have custom styles to manage different sections. May be I can just modify the phrases and variabile (with URLs) in the plugin? |
You can create a plugin at global start, which will allow your variable to be used in most templates. In others, you may have to use the PHP $GLOBALS[] array to access it, or alternatively, make the variable available by creating a plugin just before the template is parsed and bring the variable into scope.
|
Thanks Dismounted,
can you guide me? I wrote my plugin at Global Start Code:
if ($_GET['fref']=='PS') $_SESSION['fref']='PS'; Code:
$GLOBAL['pfer'] |
Have you tried just using $pfer? Once you set a variable in global_start, you should be able to use it just about anywhere.
Also, the procedure for globalizing a variable is as follows: PHP Code:
|
Hi Gio,
can yoiu help me to write this little piece of code? My plugin now is (triggered at global_start): Code:
global $fref; Code:
<a href="$fref">XXXXXXXXXXXXXX</a> May be I mistake something? Thanks. |
but in this forum there is someone who answers and helps people?
hours that are around on this forum. (in vb 3.x NOT 4 !!!) show variable from plugin to template !!!! --------------- Added 20 Mar 2012 at 15:36 --------------- Code:
global $test; $test = '<h1>hello</h1>'; I want simply to see the contents of the variable $test in header template understand? if I put $test in header template, $test is empty how the heck do you? |
It seems like that should work. Are you sure you set the plugin to active?
|
Quote:
|
OK, I just tested it and it works for me. Maybe view the html source of your page and see if it appears? I've sometimes added something that didn't show up and found out that it was actually in the html but not showing up for some reason (although when I tested you plugin it shows a large "hello" at the top, so I'm not sure why you wouldn't see it)
|
I have seen in the page source and there is nothing
|
Are you sure you're logged in to the adminCP on the correct site? Are you viewing the style whose header template you're changing? I'm out of ideas.
|
Quote:
|
Can you see the variable in the source code if you right click on your site and view source?
|
All times are GMT. The time now is 10:29 PM. |
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:
|