vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Exporting variable from plugin to template (https://vborg.vbsupport.ru/showthread.php?t=198407)

saveriop 12-09-2008 07:44 AM

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';

$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

Code:

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?

Code:

$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:
PHP Code:

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):

Code:

global $fref;

if ($_GET['fref']=='PS') $_SESSION['fref']='PS';

$fref = 'foo';

In the header code of my style I have:

Code:

<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 ---------------

Code:

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?




All times are GMT. The time now is 05:47 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
  • Page Generation 0.01054 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete