vb.org Archive

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

Xencored 06-23-2010 08:12 PM

Registering Variables Help
 
Hey all i have a php script for random ads

PHP Code:

<?php 
$fcontents 
join (""file ("http://www.myanimeisland.com/banner_ads.txt")); 
$s_con split("~",$fcontents); 
$banner_no rand(0,(count($s_con)-1)); 
echo 
$s_con[$banner_no]; 
?>

I uploaded with the Txt file checked the URL and it works great

i than added a plugin in vbulletin

PHP Code:

ob_start();
  include(
'/home/**********/public_html/banner.php');
  
$bannerphp ob_get_contents();
  
ob_end_clean(); 

Run of the Hook Global_start

i than added
Code:

{vb:raw bannerphp}
in my template and it didnt show
i read the vb manual some more and found that in vb 4 you need to Registering Variables

PHP Code:

vB_Template::preRegister('FORUMHOME',array('includedphp ' => $includedphp)); 

Where would i but this ? ive tryed everywhere and it will not show my banners

Thanks alot

DragonByte Tech 06-23-2010 08:27 PM

try this

hook forumhome_complete
PHP Code:

$fcontents join (""file ("http://www.myanimeisland.com/banner_ads.txt"));  
$s_con split("~",$fcontents);  
$banner_no rand(0,(count($s_con)-1));

vB_Template::preRegister('FORUMHOME', array('randombanner ' => $s_con[$banner_no])); 

Then to the template add
Code:

{vb:raw randombanner}

Xencored 06-23-2010 08:51 PM

Quote:

Originally Posted by DragonByte Tech (Post 2058419)
try this

hook forumhome_complete
PHP Code:

$fcontents join (""file ("http://www.myanimeisland.com/banner_ads.txt"));  
$s_con split("~",$fcontents);  
$banner_no rand(0,(count($s_con)-1));

vB_Template::preRegister('FORUMHOME', array('randombanner ' => $s_con[$banner_no])); 

Then to the template add
Code:

{vb:raw randombanner}

Thanks but its not working also :(

Lynne 06-23-2010 09:23 PM

What template are you trying to use this in?
HTML Code:

{vb:raw bannerphp}
And, uh.... you did see this in the code where the hook is called, right?
PHP Code:

// Deprecated as of release 4.0.2, replaced by global_bootstrap_init_start
($hook vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false


Xencored 06-23-2010 09:54 PM

Quote:

Originally Posted by Lynne (Post 2058453)
What template are you trying to use this in?
HTML Code:

{vb:raw bannerphp}
And, uh.... you did see this in the code where the hook is called, right?
PHP Code:

// Deprecated as of release 4.0.2, replaced by global_bootstrap_init_start
($hook vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false


am trying to use it in

8WR_media_details
ad_navbar_below

i was testing on the FORUMHOME one tho
Thanks

Lynne 06-24-2010 04:16 AM

Well, if you want to test your originally posted code in the FORUMHOME template, the correct way to preregister the variable $bannerphp would be (where did $includedphp come from?):
PHP Code:

vB_Template::preRegister('FORUMHOME',array('bannerphp ' => $bannerphp)); 


Xencored 06-24-2010 08:55 PM

Quote:

Originally Posted by Lynne (Post 2058579)
Well, if you want to test your originally posted code in the FORUMHOME template, the correct way to preregister the variable $bannerphp would be (where did $includedphp come from?):
PHP Code:

vB_Template::preRegister('FORUMHOME',array('bannerphp ' => $bannerphp)); 


i got that from the vBulletin Manual that was an example i did add that above before and it still dont show on my pages

Lynne 06-25-2010 02:27 AM

That code won't register the variable on any page except the forumhome page so that would be the only page it would show on assuming your other code is correct. (And you shouldn't include with a full path, you need to chdir to the directory and then include it.... and if you are in the directory, then you shouldn't have to chdir anyway.)


All times are GMT. The time now is 01:03 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.01093 seconds
  • Memory Usage 1,754KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_html_printable
  • (9)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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