View Full Version : Exporting variable from plugin to template
saveriop
12-09-2008, 07:44 AM
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:
if ($_GET['fref']=='PS') $_SESSION['fref']='PS';
$pfer ? $_SESSION['fref'];
Then I would like to use $pref insede the template.
Dismounted
12-10-2008, 03:00 AM
Where do you want the variable available for use?
saveriop
12-10-2008, 05:05 AM
I need the variable in template because I need to replace profile and user links (I need to integrate with drupal user base).
Thanks
Dismounted
12-10-2008, 07:11 AM
I was trying to ask - which template?
saveriop
12-10-2008, 07:48 AM
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?
Dismounted
12-11-2008, 03:23 AM
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.
saveriop
12-12-2008, 07:17 AM
Thanks Dismounted,
can you guide me?
I wrote my plugin at Global Start
if ($_GET['fref']=='PS') $_SESSION['fref']='PS';
$pfer ? $_SESSION['fref'];
then I want tu use $pfer variable in the header section of my style; I have to use something like this?
$GLOBAL['pfer']
Thanks
Gio~Logist
12-12-2008, 03:14 PM
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:
global $var, $var2, $so_on, $so_forth;
saveriop
12-17-2008, 06:33 AM
Hi Gio,
can yoiu help me to write this little piece of code?
My plugin now is (triggered at global_start):
global $fref;
if ($_GET['fref']=='PS') $_SESSION['fref']='PS';
$fref = 'foo';
In the header code of my style I have:
<a href="$fref">XXXXXXXXXXXXXX</a>
but the $fref variable is always empty...
May be I mistake something?
Thanks.
pompaunpo
03-20-2012, 01:27 PM
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 ---------------
global $test; $test = '<h1>hello</h1>';
this is my plugin in global_start, ok?
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?
pompaunpo
03-20-2012, 02:42 PM
It seems like that should work. Are you sure you set the plugin to active?
yes sure plugin is active.
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)
pompaunpo
03-20-2012, 02:54 PM
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.
pompaunpo
03-20-2012, 04:07 PM
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.
i have only one site and only one template :mad:
Simon Lloyd
03-24-2012, 06:29 PM
Can you see the variable in the source code if you right click on your site and view source?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.