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 05-24-2007, 12:29 PM
ScubaAddict ScubaAddict is offline
 
Join Date: Dec 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do I access a variable from a custom include?

Ok, I posted this question on vb.com, and after some research figured that this is the board with the smarter people So I figured it would be answered better here.

Here it is:

I am including a file into the member profile using the plugin system (ob_start()... etc).

The plugin works fine, except for one thing:

I can't figure out how to get the username variable of the profile being viewed.

For example, if you look at this page:
http://www.scubaaddict.com/scuba-forums/member.php?u=66

I have written a customization showing the articles written by that user.

Is there any way to get access to the $vbulletin->userinfo['username'] and have the value be that user (mcm007)?

Whenever I try to access that variable from my include, it shows my username (Addict) - even though the exact same code in the template shows produces 'mcm007'.

Currently, I am snagging the uid from the Querystring and getting the username by using that uid in a query - problem is that if you access the same profile in a different manner, that querystring parameter is not available.

Does anyone know how I can use this variable like I want to? or can point me to a place that has a more detailed explanation of how to use the variables in the templates?

TIA - Addict
Reply With Quote
  #2  
Old 05-25-2007, 10:11 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$userinfo[username]

It works in the template, not sure if it works out of the template though, worth a try.
Reply With Quote
  #3  
Old 05-25-2007, 03:57 PM
ScubaAddict ScubaAddict is offline
 
Join Date: Dec 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dismounted - No, that doesn't work ($userinfo[username] contains my username when viewing someone else's profile) - but thanks for replying

Maybe I need to figure out a different way to insert my table...

---------------UPDATE----------------

Ok, there has to be a way.

If you wanted to modify this page:

http://www.scubaaddict.com/scuba-for...stposter&t=162

how would you get to that user's id, or username? It isn't in a variable anywhere. I did a print_r($vbulletin) and there is nothing with that users id or username on the above page, so how does it display the username on that page?

---------------UPDATE----------------

The only way I see to get the userid on the member profile is to drop in a conditional in the include that queries based on the querystring parameter provided.
PHP Code:
if (isset($_GET['u'])) {
$profile_uid =$_GET['u'];

} elseif (isset(
$_GET['find']) && ($_GET['find'] == 'lastposter') && (isset($_GET['t']))) {
mysql_select_db("message_boards");
$sql "SELECT post.userid FROM thread LEFT JOIN post on thread.lastpostid = post.postid WHERE thread.threadid = ".$_GET['t'];
$profile_query mysql_query($sql);
$profile_result mysql_fetch_array($profile_query);
$profile_uid $profile_result['userid'];

} elseif (isset(
$_GET['find']) && ($_GET['find'] == 'lastposter') && (isset($_GET['f']))) {
mysql_select_db("message_boards");
$sql "SELECT post.userid FROM forum LEFT JOIN post on forum.lastpostid = post.postid WHERE forum.forumid = ".$_GET['f'];
$profile_query mysql_query($sql);
$profile_result mysql_fetch_array($profile_query);
$profile_uid $profile_result['userid'];

It works for me whether they click on the users name in the forum, thread or post view.

Seems expensive, so if anyone knows of a better way, please let me know.

Addict
Reply With Quote
  #4  
Old 05-27-2007, 06:37 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No it doesn't, $bbuserinfo contains your own, $userinfo contains theirs.
Reply With Quote
  #5  
Old 05-27-2007, 01:49 PM
ScubaAddict ScubaAddict is offline
 
Join Date: Dec 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dismounted,

Are you talking in the template or an included file? In the template it shows fine, but if you put that variable in an included file, the value I am getting for both variables is my username.
Reply With Quote
  #6  
Old 05-28-2007, 05:58 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ScubaAddict View Post
Are you talking in the template or an included file? In the template it shows fine, but if you put that variable in an included file, the value I am getting for both variables is my username.
Quote:
Originally Posted by Dismounted View Post
It works in the template, not sure if it works out of the template though, worth a try.
.
Reply With Quote
  #7  
Old 05-28-2007, 03:19 PM
Kungfu Kungfu is offline
 
Join Date: Dec 2005
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ScubaAddict View Post
Dismounted,

Are you talking in the template or an included file? In the template it shows fine, but if you put that variable in an included file, the value I am getting for both variables is my username.
try to include $vbulletin globally.

Not sure what your script looks like but $vbulletin->userinfo['username'] should work.
Reply With Quote
  #8  
Old 05-29-2007, 09:15 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

He wants the loaded member profile's info, not his own...
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 07:07 AM.


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.11221 seconds
  • Memory Usage 2,242KB
  • 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
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete