1
#1
Avatars Everywhere!
Posted July 12th 2012, 10:11pm
Well, not quite. :)

But if there is a place on your phpBB3 board where a user name has a link to that member's profile, it is possible to display that member's avatar. I'm going to provide three examples where user avatars can be added to a page. The first is by far the easiest, so we'll start there...the memberlist.

Note: All examples assume that you have replaced the get_user_avatar() function in includes/functions_display.php with the function I provided in this topic. Two of the examples will cause a PHP error (and a blank page!) if you do not replace this function. So replace the function. ;)

Note: If you install the Default User Avatar modification, you can ignore the above note -- the get_user_avatar() function has already been modified for you!

The memberlist.php file defines a number of template variables that aren't used in the default memberlist. One of them happens to be the user's avatar! You can add the user's avatar to the member table in the memberlist_body.html template by using the {memberrow.AVATAR_IMG} variable.

The second example is the index/home page. Here's how to add the last poster's avatar to the Last Post column. First, you must again edit the includes/functions_display.php file. Find the following code block near the top of the display_forums() function, which is the first function in the file:

$sql_array = array(
'SELECT' => 'f.*',
'FROM' => array(
FORUMS_TABLE => 'f'
),
'LEFT_JOIN' => array(),
);

Add the following two lines immediately afterwards:

$sql_array['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = f.forum_last_poster_id');
$sql_array['SELECT'] .= ', u.user_avatar, u.user_avatar_type';

Now, near the end of the display_forums() function, find the following line:

		$template->assign_block_vars('forumrow', array(

Add the following line immediately afterwards:

			'LAST_POSTER_AVATAR'	=> get_user_avatar($row['user_avatar'], $row['user_avatar_type']),

Now save the file. You can now add the last poster's avatar in the forumlist_body.html template by using the {forumrow.LAST_POSTER_AVATAR} variable.

Finally, you can add the last poster's avatar to the topic display pages. The procedure is nearly identical to the one above. First, you must edit the viewforum.php file. Find the following code block (roughly line 335):

$sql_array = array(
'SELECT' => 't.*',
'FROM' => array(
TOPICS_TABLE => 't'
),
'LEFT_JOIN' => array(),
);

Add the following two lines immediately afterwards:

$sql_array['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = t.topic_last_poster_id');
$sql_array['SELECT'] .= ', u.user_avatar, u.user_avatar_type';

Now find the following (roughly line 665):

		$template->assign_block_vars('topicrow', array(

Add the following line immediately afterwards:

			'LAST_POST_AUTHOR_AVATAR'	=> get_user_avatar($row['user_avatar'], $row['user_avatar_type']),

Now save the file. You can now add the last poster's avatar in the viewforum_body.html template by using the {topicrow.LAST_POST_AUTHOR_AVATAR} variable.

Enjoy!
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
1
#2
Avatars Everywhere!
Posted July 12th 2012, 10:32pm
So now that you have avatars on lots more pages, let's go one step further. The following modification will allow you to put the logged-in user's avatar on EVERY PAGE! This is the modification I created to add an avatar in the member box at the top right of every page. And it's simple...so here goes.

Please log in to view this content.


Not bad, huh? :)
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Avatars Everywhere!
Posted September 29th 2013, 9:40am
in viewforum.php i try to add width and height but not work
$sql_array['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = t.topic_last_poster_id');
$sql_array['SELECT'] .= ', u.user_avatar, u.user_avatar_type,u.user_avatar_height,u.user_avatar_width';


'LAST_POST_AUTHOR_AVATAR'	=> get_user_avatar($row['user_avatar'], $row['user_avatar_type'],$row['user_avatar_height'] ? 45 : (45 / $row['user_avatar_height'])),
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
Avatars Everywhere!
Posted September 29th 2013, 10:00am
If you modified the get_user_avatar() function (read the highlighted note in the first post!), the width/height in the function are ignored. However, you can set the width/height through CSS -- something like this will work:

.lastpost .ddavatar {
max-height: 45px;
max-width: 60px;
}
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Avatars Everywhere!
Posted September 29th 2013, 10:06am
Dion said:
If you modified the get_user_avatar() function (read the highlighted note in the first post!), the width/height in the function are ignored. However, you can set the width/height through CSS -- something like this will work:

.lastpost .ddavatar {
max-height: 45px;
max-width: 60px;
}

Thank you very much ;)
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
Avatars Everywhere!
Posted September 29th 2013, 10:47am
not workink (the same big size) watever i try to do lol,
im sory for cod cos it was so simple,
better give up i guess.
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
Avatars Everywhere!
Posted September 29th 2013, 10:59am
If you provide a URL to the board where you have this installed, I'll take a look and let you know how to get it working.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Avatars Everywhere!
Posted September 29th 2013, 11:08am
Dion said:
If you provide a URL to the board where you have this installed, I'll take a look and let you know how to get it working.


is o localhost but thx for your help


Edit:
done, evrithink is working awsome very nice mod thx for sheryng with us Dion i love this mod ;)
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
1
#9
Avatars Everywhere!
Posted September 29th 2013, 11:47am
If you have been trying to install this on 3.1, then all bets are off. 3.1 is not a stable product, and even the devs recommend not using it in production.

φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Avatars Everywhere!
Posted September 29th 2013, 11:52am
thx for info but i try on localhost only then on a live forum when the 3.1 will be done(i hope sun lol) :D
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
Avatars Everywhere!
Posted September 30th 2013, 12:24pm
How to add in viewtopic.php first_poster_avatar (FRIST_POST_AUTHOR_AVATAR) ?

Image
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
1
#12
Avatars Everywhere!
Posted September 30th 2013, 1:15pm
That's easy to do! In viewtopic.php, find:

// Topics table need to be the last in the chain
$sql_array['FROM'][TOPICS_TABLE] = 't';

if ($user->data['is_registered'])
{
$sql_array['SELECT'] .= ', tw.notify_status';
$sql_array['LEFT_JOIN'] = array();

Replace this with:

// Topics table need to be the last in the chain
$sql_array['FROM'][TOPICS_TABLE] = 't';

$sql_array['LEFT_JOIN'] = array();
$sql_array['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = t.topic_poster');
$sql_array['SELECT'] .= ', u.user_avatar, u.user_avatar_type';

if ($user->data['is_registered'])
{
$sql_array['SELECT'] .= ', tw.notify_status';

Next, find:

	'TOPIC_POSTER'	=> $topic_data['topic_poster'],

Immediately afterward, add:

	'FIRST_POST_AUTHOR_AVATAR'	=> get_user_avatar($topic_data['user_avatar'], $topic_data['user_avatar_type']),

Save the file, and the avatar will be available as {FIRST_POST_AUTHOR_AVATAR} in the viewtopic_body.html template.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Avatars Everywhere!
Posted September 30th 2013, 2:19pm
Thank you very much sir :D

Is working very good,awsome work.

if someone want to use this nice addone made by Dion here it is:
in viewtopic_body.html
find:
<!-- INCLUDE overall_header.html -->
<!-- IF U_MCP --><p>[ <a href="{U_MCP}">{L_MCP}</a> ]</p><!-- ENDIF -->
<!-- IF FORUM_IMAGE -->
<img class="forum-image" src="{FORUM_IMAGE}" alt="{FORUM_IMAGE}" />
<div class="clear"></div>
<!-- ENDIF -->

after add:
<div class="forabg" style="margin:4px auto;width:60%;">
<div class="inner"><span class="corners-top"><span></span></span>
<ul class="topiclist">
<li class="header">
<dl class="icon">
<dt><b style="color:#000000; font-size:8px;">Title:</b>   <b><a href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a></b></dt>

</dl>
</li>
</ul>
<ul class="topiclist forums">
<li>
<dl>
<dd style="padding:2px; text-align: center; border:none;">

{FIRST_POST_AUTHOR_AVATAR}


</dd>
<dd class="lastpost" style="padding:5px; width:40%;">
<strong>Topic description:</strong>   <i><!-- IF TOPIC_DESC -->{TOPIC_DESC}<!-- ELSE -->No topic description<!-- ENDIF --></i>

</dd>

</dl>
</li>
</ul>
<span class="corners-bottom"><span></span></span></div></div>


Image
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
Avatars Everywhere!
Posted September 30th 2013, 6:25pm
looks nice

How would you edit the topic description of a topic though? I reckon you'll have some sort of text area for "topic description" when creating a topic but there's no code for that..?
φ
Posts: 103
Joined: July 19th 2012, 8:17pm
Location: Pennsylvania
Likes Given: 9
Likes Received: 8
Avatars Everywhere!
Posted October 1st 2013, 5:17am
Jessica said:
looks nice

How would you edit the topic description of a topic though? I reckon you'll have some sort of text area for "topic description" when creating a topic but there's no code for that..?

thx,you have to replace this line:
<strong>Topic description:</strong>   <i><!-- IF TOPIC_DESC -->{TOPIC_DESC}<!-- ELSE -->No topic description<!-- ENDIF --></i>

with your description from your mod of description.
Or let me know what mod you use for description.
Sorry for my bad english.
Edit:
For default avatar in viewtopic_body.html use this:
<!-- IF FIRST_POST_AUTHOR_AVATAR -->{FIRST_POST_AUTHOR_AVATAR}<!-- ELSE -->
<img src="{T_THEME_PATH}/images/no_avatar.gif" width="50px" height="50px" alt="" /><!-- ENDIF -->
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
Avatars Everywhere!
Posted October 1st 2013, 7:47am
Which topic description mod do you use?
φ
Posts: 103
Joined: July 19th 2012, 8:17pm
Location: Pennsylvania
Likes Given: 9
Likes Received: 8
Avatars Everywhere!
Posted October 1st 2013, 8:24am
Jessica said:
Which topic description mod do you use?


I dont use yet what you see in that code is default from phpbb just a slightly modified by me.
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
Avatars Everywhere!
Posted March 19th 2014, 3:52am
On "forumlist_body.html" this function: "{forumrow.LAST_POSTER_AVATAR}" no working
φ
Posts: 16
Joined: September 28th 2013, 10:09am
Likes Given: 27
Avatars Everywhere!
Posted March 19th 2014, 12:39pm
Hmm. I just tried this on a test board. I followed my instructions exactly, and added the avatar into forumlist_body.html as follows:

					<dd class="lastpost"><span>
<!-- IF forumrow.LAST_POSTER_AVATAR -->{forumrow.LAST_POSTER_AVATAR}<!-- ENDIF -->

I then added the following line to the top of the forumlist_body.html file:

<style type="text/css">.forabg .dd-avatar{float:left;margin-right:5px;max-width:50px;max-height:36px}</style>

After purging the cache, avatars were displayed properly in the Last Post column.

lastpost-example.png

I did update the instructions in the first post of this topic. I added a second note to inform those who have installed the Default User Avatar modification that they do not need to modify the get_user_avatar() function.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Post a reply
19 posts

Who is online

Users browsing this forum: No registered users and 0 guests