View Single Post
  #1  
Old 03-18-2013, 10:52 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 335,501
Hall of Famer is on a distinguished road
Default (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.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote