Module: User Avatar
Posted by Maurice Makaay
Re: Module: User Avatar November 14, 2008 05:05AM |
Registered: 15 years ago Posts: 10 |
What code should I user if I want to show the avatar in the header for an example? Is it possible? I've got it to work under my profile and when I am listing the thread with the following.
{IF PROFILE->mod_user_avatar}
{IF MESSAGES->mod_user_avatar}
What should I use if I always want to show the avatar in the header?
{IF PROFILE->mod_user_avatar}
{IF MESSAGES->mod_user_avatar}
What should I use if I always want to show the avatar in the header?
November 14, 2008 06:18AM |
Admin Registered: 18 years ago Posts: 8,532 |
That was not an option in the User Avatar module, but I have done a quick change on the module code that should enable the use of {USER->mod_user_avatar} at any spot in the templates. I must admit that I didn't have time to test the changed code, so you are my lab rat now ;-)
Please download and install 3.0.4, go to the admin interface to reload the module information (accessing the admin.php front page should be enough for that) and try out if you can use {USER->mod_user_avatar}.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Please download and install 3.0.4, go to the admin interface to reload the module information (accessing the admin.php front page should be enough for that) and try out if you can use {USER->mod_user_avatar}.
Maurice Makaay
Phorum Development Team



Re: Module: User Avatar November 14, 2008 07:53AM |
Registered: 15 years ago Posts: 10 |
November 14, 2008 08:10AM |
Admin Registered: 18 years ago Posts: 8,532 |
That's what one gets from not testing the code :-)
I fixed the problem. The module should work fine now.
Redownload the now fixed 3.0.4 package.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
I fixed the problem. The module should work fine now.
Redownload the now fixed 3.0.4 package.
Maurice Makaay
Phorum Development Team



Re: Module: User Avatar November 14, 2008 08:14AM |
Registered: 15 years ago Posts: 10 |
November 14, 2008 08:35AM |
Admin Registered: 18 years ago Posts: 8,532 |
The template data was overriding the avatar settings data for the user (same name in the data structure). Therefore, I changed the template variable names from {DATA->mod_user_avatar} to {DATA->user_avatar}. This way, you can now use {USER->user_avatar} without risking this template data from overriding the user settings. All existing variables that you had are still intact. I still fill those for backward compatibility.
Again, I repackaged the latest version. Dowload it, add {USER->user_avatar} to your template and see if it works. I quickly tested on my own system and this version did work for me.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Again, I repackaged the latest version. Dowload it, add {USER->user_avatar} to your template and see if it works. I quickly tested on my own system and this version did work for me.
Maurice Makaay
Phorum Development Team



Re: Module: User Avatar November 14, 2008 09:37AM |
Registered: 15 years ago Posts: 10 |
That did the trick, thank you!
//New problem below =)
Where in the database can I find the active avatar id for the user that is logged in? I need to get the active avatar outside phorum.
I found a column "data" in ph_user_custom_fields wich contains:
The text marked with red is the avatars id in the ph_files table. How do i extract the number 4 from all this, I tried a little with the php function explode(); with no luck. Is there a function in phorum wich extract all this settings somehow?
Edited 1 time(s). Last edit at 11/14/2008 09:39AM by hamatzu.
//New problem below =)
Where in the database can I find the active avatar id for the user that is logged in? I need to get the active avatar outside phorum.
I found a column "data" in ph_user_custom_fields wich contains:
P_SER:a:3:{s:10:"image_info";a:2:{i:3;a:2:{s:5:"width";i:150;s:6:"height";i:129;}i:4;a:2:{s:5:"width";i:16;s:6:"height";i:16;}}s:6:"avatar";i:4;s:22:"disable_avatar_display";b:0;}
The text marked with red is the avatars id in the ph_files table. How do i extract the number 4 from all this, I tried a little with the php function explode(); with no luck. Is there a function in phorum wich extract all this settings somehow?
Edited 1 time(s). Last edit at 11/14/2008 09:39AM by hamatzu.
November 14, 2008 09:54AM |
Admin Registered: 18 years ago Posts: 8,532 |
That is a PHP serialized data, serialized using serialize()
To get the original data back, use the function unserialize()
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
To get the original data back, use the function unserialize()
Maurice Makaay
Phorum Development Team



Re: Module: User Avatar November 14, 2008 10:12AM |
Registered: 15 years ago Posts: 10 |
November 14, 2008 10:19AM |
Admin Registered: 18 years ago Posts: 8,532 |
Yes we have a working example.
It is called Phorum ;-)
You first need to load the field from the database. Let's say that you put that field in $data. Then you can do:
IIRC, the -1 value indicates "no avatar", so that one should not be used. I think the above code does about what you need.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
It is called Phorum ;-)
You first need to load the field from the database. Let's say that you put that field in $data. Then you can do:
Language: PHP$array = unserialize($data); $avatar_id = NULL; if (isset($array[';avatar';]) && $array[';avatar';] != -1) { $avatar_id = $array[';avatar';]; }
IIRC, the -1 value indicates "no avatar", so that one should not be used. I think the above code does about what you need.
Maurice Makaay
Phorum Development Team



Sorry, only registered users may post in this forum.