Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 04-14-2009, 08:11 PM
tomotron tomotron is offline
 
Join Date: Nov 2005
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Why doesn't this code to display avatars work?

I'm trying to display avatars (hosted in the filesystem) on a non-vb page. Basically, I'm supplying a userid and want to display the avatar...

PHP Code:

$avatarid 
1;

require_once(
'./includes/functions_user.php');

$avatarurl fetch_avatar_url($avatarid);
        if (
$avatarurl[0])
        {
            
$avatarurl $avatarurl[0];
        }
        else 
        {
            
$avatarurl "noavatar.gif";
    } 
$avatarurl never contains any data

From all the examples I've read it seems like this *should* work, am I making a stupid mistake? Any help is appreciated!

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

also, just to be clear this file resides in my vbulletin directory so the path to functions_user.php should be good.
Reply With Quote
  #2  
Old 04-19-2009, 05:17 PM
tomotron tomotron is offline
 
Join Date: Nov 2005
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anybody? is there another solution to display avatars that are NOT hosted in the database on a non vb page?
Reply With Quote
  #3  
Old 04-19-2009, 05:19 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Exactly what is getting displayed in the source code? And maybe it would be better to go:
PHP Code:
       if (!empty($avatarurl)) 
        { 
            
$avatarurl $avatarurl
        } 
        else  
        { 
            
$avatarurl "noavatar.gif"
    } 
Reply With Quote
  #4  
Old 04-20-2009, 05:39 PM
tomotron tomotron is offline
 
Join Date: Nov 2005
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^ I think we're basically doing the same thing there?

When i try to run this and print the results using "echo $avatarurl;" for example I get nothing. It doesn't display noavatar.gif which should display if $avatarurl is empty.

I can replace,

$avatarurl = fetch_avatar_url($avatarid);
with
$avatarurl = 1;

and the script runs and I can display the results (which are 1), so my issue lies with the fetch_avatar_url($avatarid); portion which doesn't seem to be pulling the info it's supposed to.
Do I need to include other files to access that function?
Reply With Quote
  #5  
Old 04-20-2009, 07:07 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you look at the API for that function? I believe it returns an array. Is $avatarurl defined as an array? According to the API, that is the correct file to include.
Reply With Quote
  #6  
Old 04-23-2009, 12:52 PM
tomotron tomotron is offline
 
Join Date: Nov 2005
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah looking at the API is where I got most of this code.

The if statement should deal with the array,

basically saying if there is a value for $avatarurl[0] assign it to $avatarurl, otherwise gave $avatarurl the value "noavatar.gif"
Reply With Quote
  #7  
Old 04-23-2009, 01:07 PM
EnIgMa1234 EnIgMa1234 is offline
 
Join Date: Mar 2006
Location: .:: Ireland ::.
Posts: 1,306
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try a
Code:
print_r($avatarurl);
Reply With Quote
  #8  
Old 04-24-2009, 10:02 PM
tomotron tomotron is offline
 
Join Date: Nov 2005
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^ Tried it, I think $avatarurl = fetch_avatar_url($avatarid); just isn't working
Reply With Quote
  #9  
Old 04-24-2009, 11:11 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try looking in the vb code to find a some code where this function is and then just copying it?

And, if $avatarurl is defined as an array, you can't then just go use it as if it isn't an array.
Reply With Quote
  #10  
Old 05-04-2009, 06:19 PM
tomotron tomotron is offline
 
Join Date: Nov 2005
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Did you try looking in the vb code to find a some code where this function is and then just copying it?

And, if $avatarurl is defined as an array, you can't then just go use it as if it isn't an array.
I'm not so sure I think the problem is in my code, but more than I'm trying to do this on a non-vb page and there's a step I'm missing to be able to use that function.

$avatarurl is an array, but I am using it as one... $avatarurl[0] would access the first element in the array which should be the URL for the avatar.
Reply With Quote
Reply

Thread Tools
Display Modes

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 02:07 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02372 seconds
  • Memory Usage 2,245KB
  • 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_code
  • (2)bbcode_php
  • (1)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