View Full Version : Variable Relocation
SaintDog
06-18-2002, 07:35 PM
It has been a while since I needed to request anything, most anything that I needed was already being released or had been released some time ago :). I want to thank all the code hackers for that, makes my life a lot easier.
----------
Down to the request, what I need is to be able to use the statistics variables in the header template, as well as the forumhome template (currently they can only be used in the foumhome template).
The statistics variables are the ones that state the member count, total thread & post count, the Un-Registered/Registered welcome message (ie: Welcome Back SaintDog!).
I would appreciate it very much if someone could make it to where I could use these variables in the header template.
Regards,
- SaintDog
Xenon
06-18-2002, 09:07 PM
hmm, i'm not really sure, but try this:
copy this code from index.php
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);
// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);
// get newest member
$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
$newusername=$getnewestusers['username'];
$newuserid=$getnewestusers['userid'];
// if user is know, then welcome
if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
eval("\$welcometext = \"".gettemplate('forumhome_welcometext')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logoutcode')."\";");
eval("\$newposts = \"".gettemplate('forumhome_newposts')."\";");
} else {
$welcometext = "";
eval("\$newposts = \"".gettemplate('forumhome_todayposts')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logincode')."\";");
}
just before this line in global.php
// ###################### Start headers #######################
then add the variables you want to the headertemplate
SaintDog
06-18-2002, 09:13 PM
Does not seem to work :( - I do appreciate you trying though :)
- SaintDog
Xenon
06-18-2002, 09:18 PM
oh, i see a fault ;)
try to put the code from index.php just before this line in global.php:
// parse css, header & footer ##################
SaintDog
06-18-2002, 09:27 PM
That does not work either....
- SaintDog
Grab whatever variables you need in the PHP Include template thing, so copy that code into that template. I think that should work. :D
SaintDog
06-18-2002, 10:01 PM
That too does not work, I tried placing the code from index.php in there and nothing happened, no errors, but nothing worked either.
- SaintDog
You could use this hack for a base to see how it might be done.
https://vborg.vbsupport.ru/showthread.php?s=&threadid=33048&highlight=online+users+header
Logician
06-19-2002, 07:47 AM
Saintdog: what Xenon suggested is correct and does the trick. Pls double check your steps. For instance did you add the variable $numbermembers to header template after the adding the code to global.php?
SaintDog
06-19-2002, 07:50 AM
Yes, that does not work for me at all, vBT is unhacked - this would be #1 for vBT, everything else is simply template modifications.
- SaintDog
Logician
06-19-2002, 09:12 AM
it works for me..(tested)
midad
06-19-2002, 09:13 AM
That's really fantastic...good luck :D
SaintDog
06-19-2002, 05:03 PM
I don't know what is wrong then, I can get it to work if I place the queries in the PHP Pased Code template (above the head insert), but when I place them in global.php it does not work for me.
I have tried it with brand new files, with the old files, it still does not work for me for some reason.
- SaintDog
Xenon
06-19-2002, 05:58 PM
then place them in th PHPinclude template when it worked there ;)
@Logician: thanks, have had panic my code doesn't work ;)
Logician
06-19-2002, 06:33 PM
Originally posted by Xenon
@Logician: thanks, have had panic my code doesn't work ;)
yw.. you code works, as usual.. ;)
SaintDog
06-19-2002, 06:45 PM
Thanks everyone, I finnally got it to work as I wanted it to, now on to modiying the remaining templates (I am going to hate having to redo all this for vB3 ;)).
The problem was I had the queries in global.php and in the PHP Parsed code, for some reason, having them in both was causing a conflict, by taking it out of the PHP Parsed Code section, it worked just fine.
Once again, thanks (Mr.E, Logician, and Xenon),
- SaintDog
Xenon
06-19-2002, 06:50 PM
np, glad to can be of help :)
good to know never put the same querey to php-include and global.php
* Xenon makes a mark in his brain :)
oh yeah, vb3 there'll be a lot of work for all of us
*scaried*
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.