2 Jan #1

Show hovercard with "last poster avatar" plugin

Regular user
First of all a big thank you for this fantastic plugin. I should have it tried earlier!

It works very well on my installation. Just one thing I would like to get done.
I am using the plugin last poster avatar from whiteneo.
It would be great if the card appears when hovering over the plugins avatar.

I am not sure how to achieve this. The variable for the avatar with this plugin is:

The default variable is:

Currently the hovercard only shows with the default variable.
Is there a way to modify hovercard so that it is triggered as well with the other variable?

Thanks for any pointer!
  • 1
  • 2
Shade 2 Jan
Hello, thank you for supporting me by buying Hovercards. As stated in the release thread, cards are triggered by links with the data-uid attribute. The uid is a unique identifier which MyBB uses to recognize users across the board. Therefore, all third party plugins are compatible with Hovercards as long as you perform the necessary edits: in your case, you should wrap the last poster avatar variable into a HTML "a" element with the data-uid attribute. Example:

<a data-uid="{$thread['lastposteruid']}">{$thread['avatarep']}</a>
Note that I don't know how does the plugin work, so I just suppose the avatar is evaluated within the avatarep key. Adjust as needed. If you need further help, feel free to ask.
stefan72 likes this post
stefan72 2 Jan
Thanks for the prompt and useful suggestion. Tried a few ways to wrap an "a" element but was not successful.
The code that renders the avatar of the thread starter (viewing the list of threads)  is:
Tried with this but it's not working, probably because data-uid and avatar_uid "collision"?
<a data-uid="{$thread['uid']}"><avatarep_uid_[{$thread['uid']}]>{$thread['avatarep']}</a>
Many thanks for your support.
Shade 3 Jan
I will have a look to the plugin and get back at you as soon as possible.
Shade 3 Jan Edited
The following edit should do the trick. Find in inc/plugins/avatarep.php, line 723:

$user['avatar'] = '<div class="avatarep_fd">' $user['avatar'] . '</div>'
Replace with:

$user['avatar'] = "<a data-uid='{$user['uid']}'>{$user['avatar']}</a>"
The edit is necessary for this plugin since the avatar is wrapped in an hardcoded "div", which can't semantically be inside an "a" element. AFAIK, LPA adds its own profile popup, which is removed by the edit.
stefan72 3 Jan
Thank you for checking about it on the LPA plugin. This feature seems to be a tricky one ;)
I've replaced the code as shown above and used
<a data-uid="{$thread['lastposteruid']}">{$thread['avatarep']}</a>
to call the hovercard. Tried also
<a data-uid="{$thread['uid']}">{$thread['avatarep']}</a>
But something is still not right. Sorry if I use your time with this! After all it is somewhat cosmetic. If it would work, I could remove the username and just display the avatar. It would make the forum a bit less cluttered.
Shade 3 Jan
Ah sorry, forgot to mention that you don’t need to alter the template if you have applied the edit. So just {$thread[‘avatarep’]} should suffice.
stefan72 4 Jan
Thanks Shade,
With the fix in avatarep.php applied, and original code <avatarep_uid_[{$thread['uid']}]>{$thread['avatarep']} the avatar is rendered, but no hovercard.
With only, {$thread['avatarep']} the avatar is not shown.
The full line of code as it stands now looks like this:
<span>{$prefix} {$gotounread}{$thread['threadprefix']}<span class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}"><avatarep_uid_[{$thread['uid']}]>{$thread['avatarep']}<a href="{$thread['threadlink']}">{$attachment_count} {$thread['subject']}</a></span>{$thread['multipage']}</span>
Perhaps this holds the key to the solution?
Shade 5 Jan
I’ll install the plugin on a test board and let you know ASAP.
stefan72 5 Jan Edited
The modified avatarep.php actually produces in MyBB admin the following error when cklicking on "Plugins":
Fatal error: Cannot redeclare avatarep_info() (previously declared in /kunden/xyz/hosting/9999/2345/magento_staging/forum/inc/plugins/avatarep.php:66) in/kunden/xyz/hosting/9999/2345/magento_staging/forum/inc/plugins/orig_avatarep.php on line 93