PDA

View Full Version : Using welcome variables in header


pawel
05-23-2003, 02:48 PM
Hi,
How can I use the welcome panel variables such as $welcometext in my header template? I would like the user information when logged in to appear on all the VB pages.
Thank You,
Pawel

Xenon
05-23-2003, 03:55 PM
instead of inserting the welcomepanel code into index.php you have to insert it into global.php before $header is parsed.

but you shouldn'T do that, as it would increase every page's queries

pawel
05-26-2003, 07:21 PM
Hi,
I put in all the variables into global.php but it still won't work. Here is what I put at the bottom of global.php:

//check usergroup of user to see if they can use PMs
//$permissions=getpermissions($forumid);
if ($enablepms==1 and $permissions['canusepm'] and $bbuserinfo['receivepm']) {
$ignoreusers="";
if (trim($bbuserinfo['ignorelist'])!="") {
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' ', trim($bbuserinfo['ignorelist'])));
}

$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");

if ($newpm['messages']==0) {
$lightbulb='off';
} else {
$lightbulb='on';
}
eval("\$pminfo = \"".gettemplate('forumhome_pmloggedin')."\";");

} else {
$pminfo='';
}

$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')."\";");
}


Now, when I use the variable $welcometext in the header.htm template it doesn't show up.
Thank You,
Paul

pawel
05-26-2003, 07:22 PM
Oh and by bottom I mean above ?>
Thanks,
Paul

Xenon
05-26-2003, 07:36 PM
reread my post again!

i said put the code before $header is parsed, not at the end of global.php

pawel
05-26-2003, 07:45 PM
Sorry just woke up :), I will try it as soon as I get back home.
Thank You,
Paul

assassingod
05-26-2003, 07:53 PM
Add that code before:


if ($nocacheheaders and !$noheader) {

In global.php:)

pawel
05-27-2003, 10:46 PM
Thanks Xenon, it worked perfectly. Assassingod I would try that but since I have it working I don't have time to mess with it, thanks for the help though.
Paul