View Full Version : Placing some vb elements into non-bv pages
Chris11987
08-18-2008, 10:23 AM
Can someone tell me what I would need to do to let certain elements of the forums (like PM total, username/login, avatar etc) appear on a custom, non-vb page (and not in the forums directory)? All I found so far was an article about creating vb-powered pages using templates, which isn't what I'm looking for.
Marco van Herwaarden
08-18-2008, 10:49 AM
You can use the same article and just not use the template system.
Chris11987
08-18-2008, 11:05 AM
<a href="https://vborg.vbsupport.ru/showthread.php?t=62164" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=62164</a>
That was the article I mentioned. It seems as if the page itself is being ran by vbulletin, though.
Marco van Herwaarden
08-18-2008, 11:12 AM
As long as you inclide global.php you can use any php script, or just use the example in the above thread and remove calling the templates etc.
boxerman
08-18-2008, 11:32 AM
Hi,
how would iuse a require fuction on the vb powered page?
<?php
"staff/request.php";
?>
thats what im using, but its not displaying :(
Marco van Herwaarden
08-18-2008, 11:43 AM
Please start your a new thread describing your problem.
Chris11987
08-19-2008, 01:50 AM
Everytime I use include or require_once, for the global.php file, it results in a fatal error and is unable to load the page.
Marco van Herwaarden
08-19-2008, 06:57 AM
Without knowing the code you are now using or the error message you get, we can't give more assistence.
Chris11987
08-19-2008, 09:52 AM
Warning: require_once (*********************) [function.require-once]: failed to open stream: No such file or directory in ***************/forums/global.php on line 20
I'm trying to make this page outside of my forums directory.
Marco van Herwaarden
08-19-2008, 10:54 AM
You still have not provided the code you are using, nor the full error messages.
Lynne
08-19-2008, 02:59 PM
I'm trying to make this page outside of my forums directory.
You need to chdir to the forums directory:
chdir ('/path/to/your/forums');
require_once('./global.php');
Chris11987
08-19-2008, 07:08 PM
I did that and the page is coming up without error now, but nothing from vb works when I place it on the page, like avatars for example. I tried this code for an avatar:
<table cellpadding="0" cellspacing="0" align="left" style="margin-top:5px;">
<tr>
<td><a href="$vbpoptions[bbdir]/profile.php?$session[sessionurl]do=editavatar"><img src="$vbpoptions[bbdir]/image.php?u=$bbuserinfo[userid]" alt="Your avatar" border="0" /></a>
</td>
Lynne
08-19-2008, 07:45 PM
I don't believe that is the code to get you to the avatar. You are calling a script (image.php) not an image. You need to call an actual image in order to have an image displayed. Where did you get that code from?
Chris11987
08-19-2008, 10:07 PM
From the article. What would be the proper code to display an avatar for a member if they were logged in?
Lynne
08-19-2008, 10:56 PM
From the article.
Hmmm, I tried to look but couldn't find it in there. Perhaps they were using an older version of vbulletin or something.
I'm not really sure what to use for the avatar. I looked in the postbit template and this is what is in there:
<a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$post[avatarurl]" $post[avwidth] $post[avheight] alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a>
I'm not sure that the post variable is available to you. You may have to replace that with $user and see if that works.
Dismounted
08-20-2008, 06:31 AM
Avatars can be accessed using image.php - but only if avatars are stored in the database. You can access avatars stored in the file system using fetch_avatar_url().
Chris11987
08-20-2008, 11:16 AM
Mine are stored as files, so I'd need to use fetch. Can you give me the exact code (using an example file path) I would need for an avatar to appear?
Lynne
08-20-2008, 03:52 PM
Take a look in member.php around line 395:
// AVATAR
$avatarurl = fetch_avatar_url($userinfo['userid']);
if ($avatarurl == '' OR !$vbulletin->options['avatarenabled'] OR ($avatarurl['hascustom'] AND !($userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar']) AND !$userinfo['adminavatar']))
{
$show['avatar'] = false;
}
else
{
$show['avatar'] = true;
$userinfo['avatarsize'] = $avatarurl[1];
$userinfo['avatarurl'] = $avatarurl[0];
}
Does that help?
Chris11987
08-21-2008, 05:23 AM
I then get this error:
Fatal error: Call to undefined function fetch_avatar_url() in ********************** on line 16
I'm using this code in the header:
<?php
chdir ('./forums');
require_once('./global.php');
?>
Dismounted
08-21-2008, 06:23 AM
You need to include the user functions to be able to use it:
require_once(DIR . '/includes/functions_user.php');
Chris11987
08-21-2008, 06:41 AM
<?php
chdir ('./forums');
require_once('./global.php');
require_once(DIR . '/includes/functions_user.php');
?>
I'm using that now, and still no luck.
Dismounted
08-21-2008, 09:40 AM
Please post the complete file you are using now.
Chris11987
08-21-2008, 08:10 PM
This is the entire content of the page I'm testing:
<?php
echo '<' . '?xml version="1.0" encoding="utf-8"?' . '>';
chdir ('./forums');
require_once('./global.php');
require_once('./includes/functions_user.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
// AVATAR
<?php
if ($avatarurl == '' OR !$vbulletin->options['avatarenabled'] OR ($avatarurl['hascustom'] AND !($userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar']) AND !$userinfo['adminavatar']))
{
$show['avatar'] = false;
}
else
{
$show['avatar'] = true;
$userinfo['avatarsize'] = $avatarurl[1];
$userinfo['avatarurl'] = $avatarurl[0];
}
?>
Dismounted
08-22-2008, 10:25 AM
You aren't actually using the fetch_avatar_url() function...
Chris11987
08-22-2008, 02:57 PM
Wow, how did I miss that one line? I know I was using it originally because I was getting an error from it at one time. I must have taken it out to get rid of the error.
I put it back in on the new test file I showed you and now I get a database error:
Database error in vBulletin 3.7.1:
MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
Error Number : 1064
My avatars are using my files, not my database. I double checked.
Dismounted
08-23-2008, 05:33 AM
Please post the file you are using. Just saying "I put it in" doesn't really explain where.
Chris11987
08-23-2008, 09:41 AM
There.
The url of the file is mydomainname.com/avitest.php, and the url of my forums is mydomainname.com/forums/, it that helps.
Dismounted
08-23-2008, 11:02 AM
$vbulletin->userinfo is the array for the logged in user's info, not $userinfo.
Chris11987
08-23-2008, 09:20 PM
I replaced the $userinfo's with $vbulletin->userinfo's and still get a blank page.
Lynne
08-23-2008, 09:32 PM
I took your php page, replaced the $userinfo with $vbulletin->userinfo and I get a page that simply says:
// AVATAR
But, since you aren't using a template to spit anything out and you aren't echoing anything in your php, I would not expect any other result.
edit: I meant to add, if I add this, I get something to spit out. I'm not sure it's the best way to do this though (someone else may comment on that).
echo "<img src='/forums/" .$vbulletin->userinfo['avatarurl']. "'>";
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.