vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Avatar in header template (https://vborg.vbsupport.ru/showthread.php?t=185613)

Fraik 07-17-2008 05:12 PM

Avatar in header template
 
I am trying to show the user's current avatar in the forum header (version 3.7). I used this code in my vB 3.6 setup, which displays the users' current avatar, or the default avatar if they do not have one or aren't logged in.
HTML Code:

            <if condition="$vbulletin->userinfo['avatarid']">
    <img src="$bbuserinfo[avatarpath]" alt="$bbuserinfo[username]'s Avatar" border="0" width="64" height="64" />
<else />
      <if condition="$vbulletin->userinfo['hascustomavatar']">
          <if condition="$vbulletin->options['usefileavatar']">
            <a href="profile.php?do=editavatar"><img src="$vboptions[avatarurl]/avatar$bbuserinfo[userid]_$bbuserinfo[avatarrevision].gif" title="$bbuserinfo[username]'s Avatar" alt="Avatar" border="0" width="64" height="64" /></a>
          <else />
            <a href="profile.php?do=editavatar"><img src="image.php?u=$bbuserinfo[userid]&amp;dateline=$avatar[dateline]" title="$bbuserinfo[username]'s Avatar" alt="Avatar" border="0" width="64" height="64" /></a>
          </if>
      <else />
        <a href="profile.php?do=editavatar"><img src="$stylevar[imgdir_misc]/noavatar.gif" alt="guestavatar.gif" title="No Avatar Specified" border="0" width="64" height="64" /></a>
      </if> 
</if>

The above code works in determining if someone has a custom avatar or not, but does not return the img src for the avatar - while it did in vB 3.6

Any help on fetching the users current avatar in the header template?

Thanks,
Freek

Dismounted 07-18-2008 07:21 AM

You'll find a clue in class_core.php (vB_Session constructor).

With your code, you would've needed a plugin to fetch the data - the data isn't there by default.

Fraik 07-18-2008 01:19 PM

Ah

My code works a 100% with this line added in the config.php file:
define('AVATAR_ON_NAVBAR', 1);

:D

Dismounted 07-19-2008 04:21 AM

See, a bit of searching and you get a solution ;). Also, you don't have to have that code in config.php - you can have it in a plugin at init_startup. Furthermore, consider using the function fetch_avatar_from_userinfo, rather than putting all the logic in your templates.


All times are GMT. The time now is 07:08 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.00976 seconds
  • Memory Usage 1,721KB
  • 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_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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