PDA

View Full Version : Var Plugin into template forumdisplay


Asterix_ita
11-18-2009, 10:41 AM
I apologize for my bad English, we come to my problem

I created this plugin VB3

Hook: forum display_complete


if ($_SERVER['PATH_TRANSLATED'])
{
$path = $_SERVER['PATH_TRANSLATED'];
}
else if ($_SERVER['SCRIPT_FILENAME'])
{
$path = $_SERVER['SCRIPT_FILENAME'];
}
else
{
}

$path_head = substr($path, 0, (strlen($path) - 17));

$file = $path_head.'/head/'.$foruminfo[forumid].'.html';
if(file_exists($file))
{
$head_forum = file_get_contents($file);
}
else {

}


The result was called into the template via this code

<if condition='$head_forum'>
<br />
$head_forum
<br/>
<else />&nbsp;</if>
<!-- / Asterix special header -->



With vb4 I tried to change the code but not reported any results, the plug remained unchanged.



<!-- Asterix Special header -->
<vb:if condition="$head_forum">

{vb:raw head_forum }

<vb:else />{vb:raw file} Pippo prova&nbsp;</vb:if>
<!-- / Asterix Special header -->



The $head_forum is no longer being charged and even the variable $ file. Why?

Thanks

Lynne
11-18-2009, 01:45 PM
One of the big changes in vB4 is that you MUST register your variable for use in a template. It's basically like telling the system that you created a variable $head_forum that you want to use in template xxxxx. So, while rendering template xxxxx, you need to say "Oh, I've got a variable $head_forum that I want to use in here". You haven't done that. You are going to have to change your plugin to do this. See this tutorial along with several blog posts on vb.com about this subject - [HOW TO - vB4] Rendering templates and registering variables - a short guide. (https://vborg.vbsupport.ru/showthread.php?t=228078) You will also have to register the variable file. Your template looks fine after you register the variables.

Asterix_ita
11-18-2009, 04:21 PM
thanks for the answer I try with the guide, but not create a new template as it uses forumdisplay

--------------- Added 1258574820 at 1258574820 ---------------

Sorry for the double post, solved by adding the plugin

vB_Template::preRegister('FORUMDISPLAY',array('hea d_forum' => $head_forum));

Thanks