vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Need to clearify how to preRegister to template (https://vborg.vbsupport.ru/showthread.php?t=249051)

OscarJohansson 08-21-2010 10:46 AM

Need to clearify how to preRegister to template
 
Hi all,

I've spent the entire yesterday and today morning reading on how to use custom PHP code through plugins and referring to plugin-variables in a template, and I still haven't got it working. The approach to do this still seems a bit blurry even after reading multiple articles covering the subject, so please bear with me on these basic questions.

From my understanding you can't register a variable in existing templates, such as FORUMHOME. This is where I would like my code to be inserted. Do do that I need to preRegister the variable from my plugin code.

What I did was to make a new plugin. I made a name for it and set hook_location to global_start (If anyone has any links on when to use what hook please share). I leave execution order to 5 and the actual code for my new plugin looks like this:

PHP Code:

$customCode "This is your custom code output!";

vB_Template::preRegister('FORUMHOME',array('customCode_ output' => $customCode)); 

If I got things right, I can access the variable only from the FORUMHOME template, because that's to where I registered it. And to access the variable I type this:

PHP Code:

{vb:raw customCode

And there's the problem for me. Nothing shows up when I refresh my forum. I expect the contents of the variable "This is your custom code output!" to be shown but it's all just blank. What am I doing wrong and what is the proper way to do it?

Any help appreciated! Thank you.

snakes1100 08-21-2010 01:02 PM

global_start is deprecated since 4.0.2. use global_bootstrap_init_start instead

OscarJohansson 08-21-2010 08:58 PM

Thank you! Had no idea.


All times are GMT. The time now is 02:32 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.00928 seconds
  • Memory Usage 1,715KB
  • 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
  • (2)bbcode_php_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