View Full Version : Can someone Walk me through it?
JakeC
12-10-2002, 04:47 AM
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.
Xenon
12-10-2002, 04:03 PM
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
Graphics
12-10-2002, 04:05 PM
LOL i don't think instilling hacks is that hard most of the time there is a help file :D
but ALWAYS try on a other forum first :D
NTLDR
12-10-2002, 06:58 PM
Make sure the variables are assigned the values before the template is evaluated.
JakeC
12-10-2002, 09:19 PM
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
NTLDR
12-11-2002, 05:33 PM
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:
$outputtext = "Hello World";
eval("\$hw = \"".gettemplate('hw')."\";");
NTLDR
12-11-2002, 05:38 PM
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]
$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:
function a($a) {
$d="1";
if ($d=="1") {
$c=2;
}
}
$d=1;
function a($a) {
global $d;
if ($d=="1") {
$c=2;
}
}
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.