Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2009, 08:27 AM
ScottC2105 ScottC2105 is offline
 
Join Date: Dec 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Website Intergration with vB 3.8

I'm currently building a website and I want to show the latest posts (I.E. new threads and the latest replies) on a sidebar on my main website. I would like to use PHP and connect to the database if possible. I want to have them in alternating rows (in div tags) for example:



I am also looking to include a login form, once a user logs in the login form area shows there username, a link to user cp, avatar and if there are any new PMs.

I have more I wish to do but I'll leave it for now.
Reply With Quote
  #2  
Old 04-17-2009, 08:53 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To do this, you will have to include vBulletin's global.php. After this, you will have access to the necessary variables and functions to show that kind of data. Most importantly for you, you will gain access to the $vbulletin->userinfo array.
Reply With Quote
  #3  
Old 04-17-2009, 09:04 AM
ScottC2105 ScottC2105 is offline
 
Join Date: Dec 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
To do this, you will have to include vBulletin's global.php. After this, you will have access to the necessary variables and functions to show that kind of data. Most importantly for you, you will gain access to the $vbulletin->userinfo array.
I don't suppose there is a link to an article, document or manual as to what the variables are etc..
Reply With Quote
  #4  
Old 04-17-2009, 09:06 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually, there isn't. What variables are you looking for?
Reply With Quote
  #5  
Old 04-17-2009, 09:08 AM
Floris Floris is offline
 
Join Date: Jan 2002
Posts: 1,898
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I recommend browsing the mods directory for your version and see if any modification comes close to what you want. They're great examples to get started.
Reply With Quote
  #6  
Old 04-17-2009, 09:12 AM
ScottC2105 ScottC2105 is offline
 
Join Date: Dec 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll be honest my PHP isn't great when it comes to functions etc. At the moment the first thing I want to do is get 10 latest posts showing on my website. Any ideas/help would be much appreciated.

--------------- Added [DATE]1239987506[/DATE] at [TIME]1239987506[/TIME] ---------------

Well I have got my latest posts to work via the external.php file. Is there anyway i could make a login box on my site and show a users username and current new messages if they are logged in.
Reply With Quote
  #7  
Old 04-17-2009, 05:38 PM
Choo Choo is offline
 
Join Date: Mar 2008
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In my last project I had the same task and I think I can help you.

At first you need to include global php such way (it is important):

PHP Code:
$dir getcwd();
chdir(PATH_TO_VB);
require 
'./global.php';
chdir($dir); 
After that you can work with vb's superobject using $GLOBALS['vbulletin'] variable. You mentioned 2 problems - last posts and authentification. OK... To get last posts you can use something like that:

PHP Code:
function get_posts($threadid)
{
    
$posts = array();
    
$query $vbulletin->db->query_read("SELECT * FROM post ORDER BY dateline DESC LIMIT 10");
    while(
$post $vbulletin->db->fetch_array($query)) $posts[] = $post;
    return 
$posts;

Where $vbulletin is vb's superobject.

And now about users. Look at $vbulletin->userinfo property, it contains information about logged user.
Reply With Quote
  #8  
Old 04-17-2009, 08:30 PM
ScottC2105 ScottC2105 is offline
 
Join Date: Dec 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Choo View Post
In my last project I had the same task and I think I can help you.

At first you need to include global php such way (it is important):

PHP Code:
$dir getcwd();
chdir(PATH_TO_VB);
require 
'./global.php';
chdir($dir); 
After that you can work with vb's superobject using $GLOBALS['vbulletin'] variable. You mentioned 2 problems - last posts and authentification. OK... To get last posts you can use something like that:

PHP Code:
function get_posts($threadid)
{
    
$posts = array();
    
$query $vbulletin->db->query_read("SELECT * FROM post ORDER BY dateline DESC LIMIT 10");
    while(
$post $vbulletin->db->fetch_array($query)) $posts[] = $post;
    return 
$posts;

Where $vbulletin is vb's superobject.

And now about users. Look at $vbulletin->userinfo property, it contains information about logged user.
Saint! It works! Thanks for everything! One quick question: How would I show a users avatar?

--------------- Added [DATE]1240006133[/DATE] at [TIME]1240006133[/TIME] ---------------

Quote:
Originally Posted by ScottC2105 View Post
Saint! It works! Thanks for everything! One quick question: How would I show a users avatar?
I got it, just link to http://forum_url_here/image.php?u=USER_ID_HERE and I can use $vbulletin->userinfo['id'] for USER_ID_HERE. .
Reply With Quote
  #9  
Old 04-17-2009, 09:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ScottC2105 View Post
I got it, just link to http://forum_url_here/image.php?u=USER_ID_HERE and I can use $vbulletin->userinfo['id'] for USER_ID_HERE. .
I believe this method will only work if you have the avatars stored in the database. If you ever move them to the file system (which you will want to do when your site gets big), then it is a bit more complicated. I believe there are modifications about putting the avatar here or there that will give you the query needed when you reach that point.
Reply With Quote
  #10  
Old 04-18-2009, 05:06 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

fetch_avatar_from_userinfo()
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:02 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.13178 seconds
  • Memory Usage 2,272KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete