4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: wildbill on May 24, 2002, 05:07:51 AM
-
Hello,
Sorry I don't speak German...
I am trying to add a php include in my header.html template. I have tried to put the include in both the "includes" folder within the root of 4images and outside of the root as well. No matter what happens, I get an error and my page won't load.
Any known issues with including code in the header such as
<?php
include('http://mysite.com/phpincludes/active_users.class.php');
$au = new activeUsers;
echo $au->numActive();
?>
When I add this in my header.html, the whole photo gallery crashes.
Any ideas?
-
I did it yesterday... with the same class:
include the class into a common php (b.e. config.php)
include('http://mysite.com/phpincludes/active_users.class.php');
$au = new activeUsers;
Then make a new template variable {U_ONLINE}, put into a template.
Then in page_header.php addd in
$site_template->register_vars(array("media_url" => MEDIA_PATH,
something like :
"u_online" => $au-> numActive(),
Thats all[/code]
-
Thanks, Jose, for your response...I haven't gotten it quite yet, however.
Here's what I've done...
I added this into config.php
include('http://mysite.com/phpincludes/active_users.class.php');
$au = new activeUsers;
In page_header.php, I added this at the very bottom. I think there may be a syntax error at the end?
$site_template->register_vars(array("u_online" => $au-> numActive(),));
Then, in footer.html, I added the variable
{u_online}
Then I tried it and it freaked out. Something like this pops up
Fatal error: Cannot instantiate non-existent class: activeusers in /home/www/mysite/gallery/config.php on line 27
Where am I going wrong?
-
Try something like this in page_header.php:
include('./includes/active_users.class.php');
$au = new activeUsers;
$users_online = $au->numActive(); //number of users online
$site_template->register_vars(array("media_url" => MEDIA_PATH,
"thumb_url" => THUMB_PATH,
...
"url_member" => $site_sess->url("member.php"),
"u_online" => $users_online,
"url_lost_password" => $site_sess->url("member.php?action=lostpassword")
));
[/code]
-
Thank god for backing up the database...that first method you gave me brought me back to an install screen...
Ok Jose, regarding the latest code you gave me...do I need ALL OF IT or just the top portion?
include('./includes/active_users.class.php');
$au = new activeUsers;
$users_online = $au->numActive(); //number of users online
I see that pesky "u_online" => $users_online,
snippet in there. I keep getting errors everytime I try this. I'm close, though, I can feel it...
My active_users.class.php sits outside of the photo gallery root. Does this matter?
-
Sorry but I don't understand why yo have had a problem with your DB.
Regarding the script:
1. is your class included?
2. have problemes declaring $au?
$au = new activeUsers;
3. After it try printing sometihng like
$users_online = $au->numActive(); //number of users online
echo $users_online;
If this work then go for the template parsing...
Put something like {u_online} y your template and then tell page_header.php to parse it...
$site_template->register_vars(array("media_url" => MEDIA_PATH,
"thumb_url" => THUMB_PATH,
...
"url_member" => $site_sess->url("member.php"),
"u_online" => $users_online,
"url_lost_password" => $site_sess->url("member.php?action=lostpassword")
));
You only have to add
u_online" => $users_online,
to the array.
If you don't tell me what kind of errors you have (or I have) I cannot help you :wink: