Advertisement:

Author Topic: Avatars on Board and/or MessageIndex  (Read 33025 times)

Offline Pipke

  • Jr. Member
  • **
  • Posts: 377
    • NRNS-GAMES
Avatars on Board and/or MessageIndex
« on: April 05, 2016, 06:27:00 PM »
Link to Mod

Avatars on Board and/or MessageIndex

For SMF 2.0.x

This mod will display the avatar of last poster in Board(Child)Index and or the avatar of first and or last poster of topics in MessageIndex.
Extra setting: Display topic starter time in MessageIndex.


Hook install

Tested only with the SMF default theme...but should work with other themes aswell!

License

 * This SMF modification is subject to the BSD 2-Clause License
 * Which can be found here
 
Settings

- Admin->Configuration->Modification Settings->Avatars on Board/MessageIndex

Languages

- English/utf8
- Spanish_latin/utf8 by Rock Lee

Changelog

Version 1.9 - May 18, 2017
- Fixed: More Undefined index and some Undefined offset errors

Version 1.8 - Jan 10, 2017
- Fixed: Admin setting "Show avatar of last poster on the BoardIndex"

Version 1.7 - Sep 01, 2016
- Fixed: The 'abm_id={}' text in subject column when avatar path is fault or been removed from server

Version 1.6 - Aug 20, 2016
- Fixed: Mod messed up array for template when Board has Child in Child and deeper Child etc.
- Fixed: The 'abm_id={}' text in last column when avatar path is fault or been removed from server

Version 1.5 - Jul 14, 2016
- Fixed: Last post link icon to topic was unclickable
- Fixed: The 'abm' text in last column on other costum themes!
- Fixed: Database error, given array of integer values is empty
- Fixed: Some undefined index errors

Version 1.4 - Jul 12, 2016
- New: Fully 'Hook' Mod
- Fixed: Query messed up the array output when id of poster was quest or deleted/removed
- Added: You can set the size of the avatars
- Added: You can change the width of the output column to make room for avatar
- Added: Avatar stays in center/equal to column/output text
- Added: SMF 'global' avatars can be set with round borders!
- Added: Avatars now display also on unread posts and new replies index

Version 1.0 - April 03, 2016
- Initial Release

Offline Rock Lee

  • Sophist Member
  • *****
  • Posts: 1,211
  • Gender: Male
  • Digitalizando un nuevo mundo :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Avatars on Board and/or MessageIndex
« Reply #1 on: April 05, 2016, 07:21:03 PM »
A really great job this change had something different when you need it but I think more than one will leave you the translation into Latin Spanish I hope you help :D


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2017
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,152
    • @fragicide on Twitter
Re: Avatars on Board and/or MessageIndex
« Reply #2 on: April 05, 2016, 07:46:51 PM »
Great work, Pipke!

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Avatars on Board and/or MessageIndex
« Reply #3 on: April 05, 2016, 11:15:04 PM »
I have a problem but maybe it is because I store member avatars as png files in another folder. That is an accepted method on SMF.

You can see the screenshot with missing avatars replaced by question mark.

It was also showing my avatar instead of the last poster inside the board with view of topics list.

Offline Pipke

  • Jr. Member
  • **
  • Posts: 377
    • NRNS-GAMES
Re: Avatars on Board and/or MessageIndex
« Reply #4 on: April 06, 2016, 03:05:04 AM »
I have a problem but maybe it is because I store member avatars as png files in another folder. That is an accepted method on SMF.

You can see the screenshot with missing avatars replaced by question mark.

It was also showing my avatar instead of the last poster inside the board with view of topics list.

ill check that later if i can do something about that.

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Avatars on Board and/or MessageIndex
« Reply #5 on: April 06, 2016, 03:53:29 AM »
It was given quite a bit of promotion as a way of improving performance - several posts on the site about it.

This is in the SMF wiki - official. The first suggestion:
http://wiki.simplemachines.org/smf/Performance_enhancements

Quote
Basic Improvements

Just about anyone can make use of these optimizations, regardless of how much control you have over your server. The first few options here can have an extremely dramatic effect on your server's performance, I've sorted them roughly in order of potential impact.
Move your uploaded avatars directory


In the administration panel, go to Attachments and Avatars, and then go to Avatar settings.

For Upload avatars to... select: Specific directory... For Upload directory: put in the raw, publicly accessible server directory you want them added to ie /var/www/yoursite/docs/forums/avs

So assuming /docs was your webroot, you would put /forums/avs for your upload URL. Do not do what I did and make it a subdirectory of your main avatars directory, SMF still handles it like an attachment directory for some reason so if someone uploads a .png avatar, someone else decides to use it and the first person replaces it with a .jpg avatar, the first will be deleted.

The benefit of this borders on the ridiculous
. Every single avatar load is another php call, which loads a session, the user's settings and permissions, the board and its theme. In addition, two additional calls to the database are made to load the avatar itself, and to increment the view counter. So not only are you reducing the processor load on your server, but you are also reducing your database load. If five different avatars are displayed on a page, that's five additional php calls and dozens of database queries getting made.

Offline nend

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,755
  • 2 deep n2 the code
    • sicommnend on GitHub
    • SIComm.us
Re: Avatars on Board and/or MessageIndex
« Reply #6 on: April 06, 2016, 08:50:23 AM »
I have a problem but maybe it is because I store member avatars as png files in another folder. That is an accepted method on SMF.

You can see the screenshot with missing avatars replaced by question mark.

It was also showing my avatar instead of the last poster inside the board with view of topics list.

ill check that later if i can do something about that.

Take a look here.
http://www.simplemachines.org/community/index.php?topic=232539.msg3841891#msg3841891

I  shared this awhile back with VB, his mod does attachments, my site does that along with embeds, avatars and images. It is a fallback method. ;)

Offline Pipke

  • Jr. Member
  • **
  • Posts: 377
    • NRNS-GAMES
Re: Avatars on Board and/or MessageIndex
« Reply #7 on: April 06, 2016, 02:41:14 PM »
It was also showing my avatar instead of the last poster inside the board with view of topics list.

Fixed this with update. Latest version is now 1.1

Offline morris91

  • Semi-Newbie
  • *
  • Posts: 10
Re: Avatars on Board and/or MessageIndex
« Reply #8 on: April 06, 2016, 02:53:50 PM »
even with 1.1 i still get blank avator images on my main board. in the categorys its fine but on the index this still happends.


Offline Pipke

  • Jr. Member
  • **
  • Posts: 377
    • NRNS-GAMES
Re: Avatars on Board and/or MessageIndex
« Reply #9 on: April 06, 2016, 02:57:10 PM »
even with 1.1 i still get blank avator images on my main board. in the categorys its fine but on the index this still happends.



can you post your website url so i can take look whats going on?

Offline Pipke

  • Jr. Member
  • **
  • Posts: 377
    • NRNS-GAMES
Re: Avatars on Board and/or MessageIndex
« Reply #10 on: April 06, 2016, 06:28:48 PM »
I have a problem but maybe it is because I store member avatars as png files in another folder. That is an accepted method on SMF.

You can see the screenshot with missing avatars replaced by question mark.

ill check that later if i can do something about that.

fixed, latest version is now 1.2

Offline morris91

  • Semi-Newbie
  • *
  • Posts: 10
Re: Avatars on Board and/or MessageIndex
« Reply #11 on: April 06, 2016, 08:10:36 PM »
even with 1.1 i still get blank avator images on my main board. in the categorys its fine but on the index this still happends.



can you post your website url so i can take look whats going on?

http://ultrastunting.net/index.php [nofollow]

Also updated to 1.2.

Offline DSystem

  • Jr. Member
  • **
  • Posts: 238
  • Gender: Male
  • EletronicaBR - Admin
    • eletronicaBR.com
Re: Avatars on Board and/or MessageIndex
« Reply #12 on: April 06, 2016, 08:45:35 PM »
Brazil Portuguese translation attached.

Offline DSystem

  • Jr. Member
  • **
  • Posts: 238
  • Gender: Male
  • EletronicaBR - Admin
    • eletronicaBR.com
Re: Avatars on Board and/or MessageIndex
« Reply #13 on: April 06, 2016, 08:49:26 PM »
With this amendment the mod is compatible with as many themes.

Code: [Select]
<search position="after"><![CDATA[<a href="', $topic['last_post']['href']]]></search>
<add><![CDATA[';
if (($modSettings['abm_messageindex'] == 'last') || ($modSettings['abm_messageindex'] == 'both'))
{
if ((filter_var($topic['last_post']['member']['avatar'], FILTER_VALIDATE_URL) === false) || (empty($topic['last_post']['member']['avatar'])))
echo'', $topic['last_post']['member']['id'] ? '<a href="' .$topic['last_post']['member']['href']. '">' : '', '<img style="',$abm_img_style,' border-radius:',$modSettings['abm_avatar_layout'] ? '50' : '0','%;" src="'.$settings['images_url']. '/abm_avatar.gif" alt="[?]" />', $topic['last_post']['member']['id'] ? '</a>' : '';
else
echo'<a href="' ,$topic['last_post']['member']['href'], '"><img style="',$abm_img_style,' border-radius:',$modSettings['abm_avatar_layout'] ? '50' : '0','%;" src="'. $topic['last_post']['member']['avatar'].'" alt="[?]" /></a>';
}
echo']]></add>
</operation>

After that had no additional themes installation error. ;)

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Avatars on Board and/or MessageIndex
« Reply #14 on: April 06, 2016, 09:42:37 PM »
Thanks, its an improvement. Not quite there yet.

The topic poster is displaying a [?]  on the left, and previous members also same rather than a default avatar.

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Avatars on Board and/or MessageIndex
« Reply #15 on: April 06, 2016, 09:52:19 PM »
And something else. I thought the display was a bit odd as only 8 topics displayed. On the second page it was almost blank. After uninstall it was fine again.

Offline morris91

  • Semi-Newbie
  • *
  • Posts: 10
Re: Avatars on Board and/or MessageIndex
« Reply #16 on: April 06, 2016, 11:14:56 PM »
With this amendment the mod is compatible with as many themes.

Code: [Select]
<search position="after"><![CDATA[<a href="', $topic['last_post']['href']]]></search>
<add><![CDATA[';
if (($modSettings['abm_messageindex'] == 'last') || ($modSettings['abm_messageindex'] == 'both'))
{
if ((filter_var($topic['last_post']['member']['avatar'], FILTER_VALIDATE_URL) === false) || (empty($topic['last_post']['member']['avatar'])))
echo'', $topic['last_post']['member']['id'] ? '<a href="' .$topic['last_post']['member']['href']. '">' : '', '<img style="',$abm_img_style,' border-radius:',$modSettings['abm_avatar_layout'] ? '50' : '0','%;" src="'.$settings['images_url']. '/abm_avatar.gif" alt="[?]" />', $topic['last_post']['member']['id'] ? '</a>' : '';
else
echo'<a href="' ,$topic['last_post']['member']['href'], '"><img style="',$abm_img_style,' border-radius:',$modSettings['abm_avatar_layout'] ? '50' : '0','%;" src="'. $topic['last_post']['member']['avatar'].'" alt="[?]" /></a>';
}
echo']]></add>
</operation>

After that had no additional themes installation error. ;)

i thought i would try this amendment . get errors but installed anyway. everything works still but the icon problem i stated above now no longer appear at all.

Offline JerzyLS

  • Semi-Newbie
  • *
  • Posts: 64
Re: Avatars on Board and/or MessageIndex
« Reply #17 on: April 07, 2016, 04:01:41 AM »
On the index is working fine.
http://spolecznosc.bialenia.org.pl/index.php

But in the boards on child boards not.
http://spolecznosc.bialenia.org.pl/index.php?board=2.0

How to solve it?

Offline JerzyLS

  • Semi-Newbie
  • *
  • Posts: 64
Re: Avatars on Board and/or MessageIndex
« Reply #18 on: April 07, 2016, 07:08:23 AM »
Okay, here is the solution for child boards.

Themes/default/MessageIndex.template

Find:

Code: [Select]
/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'], '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';

echo '
</td>
</tr>';

And replace:

Code: [Select]
/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))
$abm_img_style = 'width:42px; height: 42px; float:left; margin-right: 6px; padding: 0px;';
if (!empty($modSettings['abm_boardindex']))
{
if ((filter_var($board['last_post']['member']['avatar'], FILTER_VALIDATE_URL) === false) || (empty($board['last_post']['member']['avatar'])))
echo'', $board['last_post']['member']['id'] ? '<a href="' .$board['last_post']['member']['href']. '">' : '', '<img style="',$abm_img_style,' border-radius:',$modSettings['abm_avatar_layout'] ? '50' : '0','%;" src="'.$settings['images_url']. '/abm_avatar.gif" alt="[?]" />', $board['last_post']['member']['id'] ? '</a>' : '';
else
echo'<a href="' ,$board['last_post']['member']['href'], '"><img style="',$abm_img_style,' border-radius:',$modSettings['abm_avatar_layout'] ? '50' : '0','%;" src="'. $board['last_post']['member']['avatar'].'" alt="[?]" /></a>';
}
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'], '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';

echo '
</td>
</tr>';

Offline JerzyLS

  • Semi-Newbie
  • *
  • Posts: 64
Re: Avatars on Board and/or MessageIndex
« Reply #19 on: April 07, 2016, 02:03:46 PM »
Some errors in logs:

8: Undefined variable: abm_img_style
/Themes/default/BoardIndex.template.php
Line: 376

356:
	
	
	
	
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
357:
	
	
	
	
echo 
'
358:
	
	
	
	
	
<strong><a href="'
$scripturl'?action=recent">'$txt['recent_posts'], '</a></strong>
359:
	
	
	
	
	
<p id="infocenter_onepost" class="middletext">
360:
	
	
	
	
	
	
'
$txt['recent_view'], ' &quot;'$context['latest_post']['link'], '&quot; '$txt['recent_updated'], ' ('$context['latest_post']['time'], ')<br />
361:
	
	
	
	
	
</p>'
;
362:
	
	
	
}
363:
	
	
	
// Show lots of posts.
364:
	
	
	
elseif (!empty(
$context['latest_posts']))
365:
	
	
	
{
366:
	
	
	
	
echo 
'
367:
	
	
	
	
	
<dl id="ic_recentposts" class="middletext">'
;
368:
	

369:
	
	
	
	
/* Each post in latest_posts has:
370:
	
	
	
	
	
	
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
371:
	
	
	
	
	
	
subject, short_subject (shortened with...), time, link, and href. */
372:
	
	
	
	
foreach (
$context['latest_posts'] as $post)
373:
	
	
	
	
	
echo 
'
374:
	
	
	
	
	
	
<dt><strong>'
$post['link'], '</strong> '$txt['by'], ' '$post['poster']['link'], ' ('$post['board']['link'], ')</dt>
375:
	
	
	
	
	
	
<dd>'
$post['time'], '</dd>';
==>
376:
	
	
	
	
echo 
'
377:
	
	
	
	
	
</dl>'
;
378:
	
	
	
}
379:
	
	
	
echo 
'
380:
	
	
	
	
</div>'
;
381:
	
	
}


8: Undefined variable: board
Themes/default/BoardIndex.template.php
Linia: 375

358:
	
	
	
	
	
<
strong><a href="', $scripturl, '?action=recent">', $txt['recent_posts'], '</a></strong>
359:
	
	
	
	
	
<
p id="infocenter_onepost" class="middletext">
360:
	
	
	
	
	
	
', $txt['recent_view'], ' &quot;', $context['latest_post']['link'], '&quot', $txt['recent_updated'], ' (', $context['latest_post']['time'], ')<br />
361:
	
	
	
	
	
</
p>';
362:
	
	
	
}
363:
	
	
	
// Show lots of posts.
364:
	
	
	
elseif (!empty($context['
latest_posts']))
365:
	
	
	
{
366:
	
	
	
	
echo '
367:
	
	
	
	
	
<
dl id="ic_recentposts" class="middletext">';
368:
	

369:
	
	
	
	
/* Each post in latest_posts has:
370:
	
	
	
	
	
	
board (with an id, name, and link.), topic (the topic'
s id.), poster (with idname, and link.),
371:
	
	
	
	
	
	
subjectshort_subject (shortened with...), timelink, and href. */
372:
	
	
	
	
foreach (
$context['latest_posts'] as $post)
373:
	
	
	
	
	
echo 
'
374:
	
	
	
	
	
	
<dt><strong>'
$post['link'], '</strong> '$txt['by'], ' '$post['poster']['link'], ' ('$post['board']['link'], ')</dt>
==>375:
	
	
	
	
	
	
<dd>'
$post['time'], '</dd>';
376:
	
	
	
	
echo 
'
377:
	
	
	
	
	
</dl>'
;
378:
	
	
	
}
379:
	
	
	
echo 
'
380:
	
	
	
	
</div>'
;
381:
	
	
}