View Full Version : Help with plugin
mimidov
02-01-2011, 06:47 PM
I am trying to work out a simple plugin as follow:
location: init_startup
$savevar = 'test';
in footer template, I added the following:
{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 (https://vborg.vbsupport.ru/showthread.php?t=228078)
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:
$showdata = 'test';
$templater = vB_Template::create('mytemplate');
$templater->register('showdata', $showdata);
$templater->render();
Then I used the following line in the footer template:
{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:
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
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.