Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Tutorials and Tips (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=27)
-   -   (How to...) Add user avatar to the sidebar with Mys v1.3.3 (http://www.mysidiaadoptables.com/forum/showthread.php?t=4068)

Hall of Famer 03-18-2013 10:52 AM

(How to...) Add user avatar to the sidebar with Mys v1.3.3
 
Well this is a simple tutorial for admins to add user avatar as a module to their users, it assumes that you uses Mys v1.3.3. For earlier versions you may have to do this by editing script files, which can be a problem.

So to begin with, go to module manager in your ACP, create a new module with basic information as entered below:

It does not matter what name you give to your avatar module, but the required userlevel can be tricky. Enter 'member' as suggested above, otherwise it may attempt to get avatars for guests and return an error message.

The next thing to do is to enter the module's PHP code. The PHP code is evaluated by the script's internal code, but there are a few variables you may need to keep track of. One of them is $mysidia, which stores important system information. The other is $moduleContainer, which serves as container for your GUI module. Sounds complicated? Well for this tutorial you do not need to know how they work, since I will provide the actual code to get this avatar module done for you. However, you may want to learn a bit more about them if you plan to add some custom php code completely yourself.

Anyway, in the field 'module php code' text area, enter the following code below:

PHP Code:

$profile $mysidia->user->getprofile();
$avatar = new Image($profile->getAvatar());
$avatar->resize(200);
$moduleContainer->add($avatar); 

And we are all done, submit the form and your users will find their avatar displayed on the sidebar. You can change the value '200' in $avatar->resize(200) to get any size you want for your site, 200 is used here since the width of default sidebar column is about that size. Your user may have a problem if they have rectangular shaped avatar rather than squarely shaped, but this cant be helped. The avatar module in action is shown below:


This concludes my tutorial for how to add user avatars to your site, lemme know if you encounter any issues. Also you can change the display order for each sidebar module in ACP too, just in case you havent noticed yet. Have fun playing with the script, everyone.

Abronsyth 03-18-2013 03:33 PM

*Dances* Wonderful! I was just wondering about this too :D

Thanks, HoF ^_^

Infernette 03-18-2013 05:20 PM

Coolio! I was wondering though, how do you change the alignment of the avatar, like center or something. :)

SapphirePhoenix 12-28-2015 10:55 PM

Yay! And it works with Mys v1.3.4 as well!


All times are GMT -5. The time now is 04:49 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.