vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help with plugin (https://vborg.vbsupport.ru/showthread.php?t=258163)

mimidov 02-01-2011 06:47 PM

Help with plugin
 
I am trying to work out a simple plugin as follow:

location: init_startup
PHP Code:

$savevar 'test'

in footer template, I added the following:
HTML Code:

{vb:var savevar}
Unfortunately this didn't work. The 'test' word didn't show up in the footer.

Where is the problem?

wpeloquin 02-01-2011 07:45 PM

if you're just trying to add text, why not add a phrase and add it to the footer template?

Lynne 02-01-2011 09:48 PM

You need to also preregister the variable for use in the footer template. Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide

mimidov 02-02-2011 06:11 AM

wpeloquin, it is just an example but in the real code there are some calculations needed to be done before displaying the results in the footer

Lynne,
I read the article and modified my plugin to:
PHP Code:

$showdata 'test';
$templater vB_Template::create('mytemplate');
    
$templater->register('showdata'$showdata);
$templater->render(); 

Then I used the following line in the footer template:
PHP Code:

{vb:raw showdata

However, still nothing seems to work. Also this seems to have made errors as some links have disappeared from my forum when the plugin is active!

Lynne 02-02-2011 03:53 PM

So, you have a template named "mytemplate" and you want it to show in the footer? You still have no preregistered the variable $showdata, or the results from your created template, for use in the footer template. You'll need something like:

PHP Code:

vB_Template::preRegister('footer', array('showdata' => $showdata)); 

You'll need to do that for any variable you want to use in the footer. (Right now the results of your created template are not assigned to any variable.)

mimidov 02-02-2011 11:11 PM

finally worked :)

Thanks Lynne


All times are GMT. The time now is 08:17 AM.

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.01057 seconds
  • Memory Usage 1,725KB
  • 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
  • (1)bbcode_html_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete