vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   This piece of code is not working (https://vborg.vbsupport.ru/showthread.php?t=185445)

zmmmzz 07-15-2008 09:33 PM

This piece of code is not working
 
Im trying to display a users' avatar in navbar. I add this lines to a plugin in the global_start hook location.

PHP Code:

// include backend
require_once('./global.php');
require_once(
DIR '/includes/functions_user.php');

// setup avatar if exists
$avatar fetch_avatar_url($vbulletin->userinfo['userid']);
if (
$avatar != '' AND $vbulletin->options['avatarenabled'])
{
    
$avatarurl $avatar[0];


Then the html in the navbar template:

HTML Code:

<img src="$avatarurl" alt="Your Avatar" border="0" />
The avatar won't display. What am I doing wrong?

MoT3rror 07-16-2008 12:21 AM

This should be your plugin code. I don't know how that code is not a endless loop if you have that in global_start hook. The global file is already included so you don't need to include it again.

PHP Code:

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

// setup avatar if exists
$avatar fetch_avatar_url($vbulletin->userinfo['userid']);
if (
$avatar != '' AND $vbulletin->options['avatarenabled'])
{
    
$avatarurl $avatar[0];



Dismounted 07-16-2008 05:56 AM

Your code in the template should also take into account if the user has no avatar.
Code:

<if condition="$avatarurl"><img src="$avatarurl" alt="Your Avatar" border="0" /></if>

zmmmzz 07-17-2008 03:16 PM

I made the changes but it doesn't seems to work.
I'm using vbulletin's latest version 3.7.2 Patch Level 1. Maybe that's the problem.

noppid 07-17-2008 03:26 PM

I didn't look at the function you call, but it would seem a string return would be the result, not an array? So get rid of the [0] on $avatar and see what happens.

EDIT: It is an array. I suggest you use...

PHP Code:

echo "<pre>";
print_r($avatar); 

And see what you are getting in your array key wise and depth wise depending on the avatar you pull and the settings.

Dismounted 07-18-2008 06:03 AM

Quote:

Originally Posted by zmmmzz (Post 1577809)
I made the changes but it doesn't seems to work.

My changes were for a suggestion to fix a bug ;). You are also going about the wrong way to do this - look in class_core.php (vB_Session class constructor).


All times are GMT. The time now is 01:39 AM.

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.02135 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete