Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 12-10-2002, 04:47 AM
JakeC JakeC is offline
 
Join Date: Sep 2002
Location: Yakima, WA
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Can someone Walk me through it?

Can someone walk me through the process and theory behind making a Variable visible in a template that it was not intended for? I am trying to integrate $activeusers, $totalonline and some others into my $welcometext and they will not show up. I was told that this requires some hacking, so here I am. I am fairly proficient at modifying templates, but the inner workings of vB is a mystery. I want to change that ASAP so maybe I can give out some advice for a change. Thanks in advance.

JakeC

By the way, one of you super vB hackers out there that can swing a pen ought to write a "How to hack vB" book. Not necessarily a book on PHP per say but one that walks you through like 10-15 sample hacks from easy to complicated. I'd buy one.
Reply With Quote
  #2  
Old 12-10-2002, 04:03 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well, learning from a book don't work i think.
best way is learning by doing.
try and error rules

to answer your question:
the variables must be defined inside of the function which calls the template, so you have to edit a php-file (index.php in this case)

and there before you parse the template (gettemplate function will be seen in the sourcecode ) you have to add something like $activx = "Blabla", then you can use $activx in your template
Reply With Quote
  #3  
Old 12-10-2002, 04:05 PM
Graphics's Avatar
Graphics Graphics is offline
 
Join Date: Mar 2002
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

LOL i don't think instilling hacks is that hard most of the time there is a help file

but ALWAYS try on a other forum first
Reply With Quote
  #4  
Old 12-10-2002, 06:58 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Make sure the variables are assigned the values before the template is evaluated.
Reply With Quote
  #5  
Old 12-10-2002, 09:19 PM
JakeC JakeC is offline
 
Join Date: Sep 2002
Location: Yakima, WA
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, the light is beginning to shine a little brighter but I need you guys to break it down even further. Is there any way you could give me an example. Maybe walk me through all of the steps so I can get an idea of what is doing what and why it works. I am a rank beginner so allot of the terms and tasks you mentioned are a little new to me. Thanks.

JakeC
Reply With Quote
  #6  
Old 12-11-2002, 05:33 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
eval("\$hw = \"".gettemplate('hw')."\";");
$outputtext "Hello World"
Adding $outputtext to the hw won't work as its assigned after the template is evaluated, however doing it this way will work as its assigned before the template is evaluated:

PHP Code:
$outputtext "Hello World";
eval(
"\$hw = \"".gettemplate('hw')."\";"); 
Reply With Quote
  #7  
Old 12-11-2002, 05:38 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Xenon
to answer your question:
the variables must be defined inside of the function which calls the template, so you have to edit a php-file (index.php in this case)[/B]
PHP Code:
$d="1";
function 
a($a) {

    if (
$d=="1") {
        
$c=2;
    }

$d won't be set and can't be used, however either of the following two methods will work:

PHP Code:
function a($a) {
    
$d="1";
    if (
$d=="1") {
        
$c=2;
    }

PHP Code:
$d=1;
function 
a($a) {
    global 
$d;
    if (
$d=="1") {
        
$c=2;
    }

Reply With Quote
Reply

Thread Tools
Display Modes

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 10:42 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.04193 seconds
  • Memory Usage 2,222KB
  • Queries Executed 11 (?)
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
  • (5)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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