Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2010, 08:12 PM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 06-23-2010, 08:27 PM
DragonByte Tech's Avatar
DragonByte Tech DragonByte Tech is offline
 
Join Date: Feb 2010
Location: Scotland
Posts: 8,814
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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}
Reply With Quote
  #3  
Old 06-23-2010, 08:51 PM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DragonByte Tech View Post
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
Reply With Quote
  #4  
Old 06-23-2010, 09:23 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 06-23-2010, 09:54 PM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
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
Reply With Quote
  #6  
Old 06-24-2010, 04:16 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)); 
Reply With Quote
  #7  
Old 06-24-2010, 08:55 PM
Xencored Xencored is offline
 
Join Date: Sep 2008
Location: UK, Scuny
Posts: 1,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
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
Reply With Quote
  #8  
Old 06-25-2010, 02:27 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:08 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.03798 seconds
  • Memory Usage 2,260KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_html
  • (9)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete