What's up ladies how are you doing today? So, what are we going to talk about here, today I will show you how you can show author avatar next to the thread in MyBB forum Threadlist and Search templates! Most tutorials out there only explain how to display avatars in threadlist like XenForo but they say nothing about how to show avatars in Search results, so let me show you how to do that!
First lets add avatars to Threadlist.
Open forumdisplay.php and find:
Replace it with this code:
Now find:
Above add this code:
The final code should look like this:
Now lets add avatars to Search results.
Notice! We are only going to be adding avatars to search results threads not posts as it makes no sense heaving avatars in posts template since the results are shoving posts not threads!
Open search.php and find:
Replace it with this code:
Now find:
Add this code just above it:
The final result will look this:
Ok this concludes PHP editing part now we are going to edit templates!
Go to ACP >> Templates & Style >> Templates >> Your Template >> Forum Display Teamples > Forumdisplay_thread
Inside the template find:
Now replace the whole code above with this one:
Go to ACP >> Templates & Style >> Templates >> Your Template >> Search Teamples > search_results_threads_thread
Inside the search template find:
Now replace it with this one:
Lastly we need to add CSS style to our avatars so add this css your global.css
That is it ladies if you have any question please feel free to post them below or if you found an error I made (I am a person so I do make mistakes) please report it!

Important! If you believe you can just use a plugin for this then you have to know that a plugin will multiply your SQL queries x2.
Without plugin: SQL queries 21, with plugin: SQL queries 42 or in some case even more, this increases server and SQL load so don't use plugin unless you don't care about server load neither queries
First lets add avatars to Threadlist.
Open forumdisplay.php and find:
PHP Code:
SELECT t.*, {$ratingadd}t.username AS threadusername, u.username
Replace it with this code:
PHP Code:
SELECT t.*, {$ratingadd}t.username AS threadusername, u.username, u.avatar
Now find:
PHP Code:
$thread['pages'] = 0;
$thread['multipage'] = '';
$threadpages = '';
$morelink = '';
$thread['posts'] = $thread['replies'] + 1;
Above add this code:
PHP Code:
if(!$thread['avatar']) {
$thread_avatar = "<a href='member.php?action=profile&uid={$thread['uid']}'><img src='images/default_avatar.gif' alt='' title='{$thread['username']}' /></a>";
}
else
{
$thread_avatar = "<a href='member.php?action=profile&uid={$thread['uid']}'><img src='{$thread['avatar']}' alt='' title='{$thread['username']}' /></a>";
}
The final code should look like this:
PHP Code:
if(!$thread['avatar']) {
$thread_avatar = "<a href='member.php?action=profile&uid={$thread['uid']}'><img src='images/default_avatar.gif' alt='' title='{$thread['username']}' /></a>";
}
else
{
$thread_avatar = "<a href='member.php?action=profile&uid={$thread['uid']}'><img src='{$thread['avatar']}' alt='' title='{$thread['username']}' /></a>";
}
$thread['pages'] = 0;
$thread['multipage'] = '';
$threadpages = '';
$morelink = '';
$thread['posts'] = $thread['replies'] + 1;
Now lets add avatars to Search results.
Notice! We are only going to be adding avatars to search results threads not posts as it makes no sense heaving avatars in posts template since the results are shoving posts not threads!
Open search.php and find:
PHP Code:
SELECT t.*, u.username AS userusername, p.displaystyle AS threadprefix
Replace it with this code:
PHP Code:
SELECT t.*, u.username AS userusername, p.displaystyle AS threadprefix, u.avatar
Now find:
PHP Code:
$thread['pages'] = 0;
$thread['multipage'] = '';
$threadpages = '';
$morelink = '';
$thread['posts'] = $thread['replies'] + 1;
Add this code just above it:
PHP Code:
if(!$thread['avatar']) {
$thread_avatar = "<a href='member.php?action=profile&uid={$thread['uid']}'><img src='images/default_avatar.gif' alt='' title='{$thread['username']}' /></a>";
}
else
{
$thread_avatar = "<a href='member.php?action=profile&uid={$thread['uid']}'><img src='{$thread['avatar']}' alt='' title='{$thread['username']}' /></a>";
}
The final result will look this:
PHP Code:
if(!$thread['avatar']) {
$thread_avatar = "<a href='member.php?action=profile&uid={$thread['uid']}'><img src='images/default_avatar.gif' alt='' title='{$thread['username']}' /></a>";
}
else
{
$thread_avatar = "<a href='member.php?action=profile&uid={$thread['uid']}'><img src='{$thread['avatar']}' alt='' title='{$thread['username']}' /></a>";
}
$thread['pages'] = 0;
$thread['multipage'] = '';
$threadpages = '';
$morelink = '';
$thread['posts'] = $thread['replies'] + 1;
Ok this concludes PHP editing part now we are going to edit templates!
Go to ACP >> Templates & Style >> Templates >> Your Template >> Forum Display Teamples > Forumdisplay_thread
Inside the template find:
PHP Code:
<div>
<span>{$prefix} {$gotounread}{$thread['threadprefix']}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}</span>
<div class="author smalltext">{$thread['profilelink']}</div>
</div>
Now replace the whole code above with this one:
PHP Code:
<div>
<table><tr><td id="tvatar">{$thread_avatar}</td><td>{$prefix} {$gotounread}{$thread['threadprefix']}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}<br> {$thread['profilelink']}</td></tr></table>
</div>
Go to ACP >> Templates & Style >> Templates >> Your Template >> Search Teamples > search_results_threads_thread
Inside the search template find:
PHP Code:
<div>
<span>{$prefix} {$gotounread}{$thread['threadprefix']}<a href="{$thread_link}{$highlight}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}</span><div class="author smalltext">{$thread['profilelink']}</div>
</div>
Now replace it with this one:
PHP Code:
<div>
<table><tr><td id="tvatar">{$thread_avatar}</td><td>{$prefix} {$gotounread}{$thread['threadprefix']}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}<br> {$thread['profilelink']}</td></tr></table>
</div>
Lastly we need to add CSS style to our avatars so add this css your global.css
Code:
That is it ladies if you have any question please feel free to post them below or if you found an error I made (I am a person so I do make mistakes) please report it!

Important! If you believe you can just use a plugin for this then you have to know that a plugin will multiply your SQL queries x2.
Without plugin: SQL queries 21, with plugin: SQL queries 42 or in some case even more, this increases server and SQL load so don't use plugin unless you don't care about server load neither queries
