vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Var Plugin into template forumdisplay (https://vborg.vbsupport.ru/showthread.php?t=228288)

Asterix_ita 11-18-2009 10:41 AM

Var Plugin into template forumdisplay
 
I apologize for my bad English, we come to my problem

I created this plugin VB3

Hook: forum display_complete

Code:

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

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.



Code:

<!-- 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. 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 [DATE]1258574820[/DATE] at [TIME]1258574820[/TIME] ---------------

Sorry for the double post, solved by adding the plugin

Code:

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


All times are GMT. The time now is 08:58 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.01620 seconds
  • Memory Usage 1,716KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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