News:

Join the Facebook Fan Page.

Main Menu

Displaying Avatar

Started by citizenerased, July 26, 2011, 01:39:38 PM

Previous topic - Next topic

citizenerased

Hi guys,

I have a table named db_prefix_likes. It's like:

like_id | liked_topic | liked_message | liked_user | liked_user_name | liken_user | like_date

I want to display liked_user's avatar. How can I do this?

All Colours Sam

where exactly do you want to display the avatars?   the table does not really matter, all that matter its that you have liked_user   which I'm guessing has the user id, with that you can do a LEFT JOIN with the members and attachments table to get the proper data.


with that said I believe you will fine a more appropriate response in the support topic for the mod you are currently using.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

citizenerased

I wanna display avatars on post area in display.template. i write script for my site. so i can't share my codes. can you tell me how i make this?

All Colours Sam

are you using a mod?

what SMF are you using?


asusming you are using 2.0 on your  query to get the people who had "liked"  certain topic or message  you will need to add a left join:


               LEFT JOIN {db_prefix}members AS m ON (m.id_member = l.liked_user)
               LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = l.liked_user)


of course you will have to call all the appropriate columns:

m.id_member, m.real_name,
               m.avatar, a.id_attach, a.attachment_type, a.filename


then you can have access to the user avatar:


'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),



that is assuming  liked_user  its the user ID.


thats all the info I cna give you since you don't provide enough details.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

citizenerased

I'm using SMF 2.0.

Installed mods on my forum;

1.    Member Color Link    3.1
2.    nCode Image Resizer    1.3.1
3.    Sitemap    2.2.0
4.    YouTube BBCode    2.6
5.    Pretty URLs    1.0RC5.2
6.    Referrals System    3.0.1
7.    SimplePokes    1.1

And I have my own modification called AjaxLikes. For show who liked the message, I need to display their avatar. I can't understand SMF Query Language, so I don't know where and how can I use your codes. Can you help me?

All Colours Sam

I don't know what code you used, I don't know how is coded,  I can only suggest you what I said above,  just add the left join in your query.

or you can ask for support to whoever coded this AjaxLikes mod.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Advertisement: