[HOW TO] Add avatar to pages

How-to's, little tricks, tutorials, code examples (snippets) and read-me's.

Re: [HOW TO] Add avatar to pages

Postby topdown » 14 Mar 2009, 23:51

Remove the edits you made and
OPEN phpBB_forum/includes/functions.php

FIND
Code: Select all
   // The following assigns all _common_ variables that may be used at any point in a template.


BEFORE ADD
Code: Select all
    if ($user->data['user_avatar'])
    {
        if (!
function_exists('get_user_avatar'))
        {
            include 
$phpbb_root_path 'includes/functions_display.' $phpEx;
        }
            
$template->assign_vars(array(
                
'S_AVATAR'           => ($user->data['user_avatar'] != '') ? true false,
                
'MY_AVATAR'         => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']),
                
'MY_NAME'            => get_username_string('full'$user->data['user_id'], $user->data['username'], $user->data['user_colour']),
            ));
    } 


Template variables
S_AVATAR = <!-- IF S_AVATAR -->{MY_AVATAR}<!-- ENDIF --> If avatar is true, show
MY_AVATAR = {MY_AVATAR} is the avatar itself
MY_NAME = {MY_NAME} Your user name, profile link and color
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 3021
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 9


Re: [HOW TO] Add avatar to pages

Postby Flick » 15 Mar 2009, 06:57

Brilliant, the only problem I'm now having is users with out a avatar can not see their username. :s

Edit: Nevermind, I just moved the "'MY_NAME' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour'])," in with the rest of the template variables and it works.

Perfect, thank you very much! :hello:
Flick    
Cadet II
Cadet II
 
Posts: 22
Joined: 04 Aug 2008, 11:56
Location: Liverpool, UK
Favorite Team: The LSU Team
Gender: Male
phpBB Knowledge: 3

Re: [HOW TO] Add avatar to pages

Postby topdown » 15 Mar 2009, 11:11

That is correct, you would need
{MY_NAME} outside of the <!-- IF S_AVATAR --> statement.
Good to see you got it fixed up. :)
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 3021
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 9

Re: [HOW TO] Add avatar to pages

Postby Sniper_E » 15 Mar 2009, 11:51

Show us a screen shot of what you have created Flick. How awesome does it look so far?
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
User avatar
Sniper_E    
STG Jedi Master
STG Jedi Master
 
Posts: 6979
Joined: 31 May 2006, 06:29
Location: Shreveport, LA
Favorite Team: The STG Team
Gender: Male
phpBB Knowledge: 6

Re: [HOW TO] Add avatar to pages

Postby Flick » 15 Mar 2009, 20:50

Haha okay, here's one of the board index so far. Granted this is a low quality picture as I'm connecting on mobile internet atm.

board.jpg
Index Page for Schola


And another of the blog index, which once I have everything sorted with that will become the site index.

blog.jpg
Blog index


There's still a quite a bit for me to do on the site, but its now mostly just graphical improvements.
Flick    
Cadet II
Cadet II
 
Posts: 22
Joined: 04 Aug 2008, 11:56
Location: Liverpool, UK
Favorite Team: The LSU Team
Gender: Male
phpBB Knowledge: 3

Previous

Return to Tutorials and How-Tos

Who is online

Users browsing this forum: No registered users and 6 guests

cron