SocialEngine Zend getting user profile picture

戏子无情 提交于 2019-12-06 16:13:09

问题


I am trying to get a users profile picture by using

$this->itemPhoto($this->viewer(), 'thumb.icon');

or

$this->htmlLink($this->viewer()->getHref(), $this->itemPhoto($this->viewer(), 'thumb.icon'))

The this->viewer gets the person who is viewing the page and outputs their user_id and a link. I mimicked the output of that but it refuses to accept it. It errors out with 'Item must be a valid item." I have searched through the code and when users upload images it for some reason is hashed and put into hashed folders which i can't just pull from. But using the above functions do not work if i wanted to get the profile picture of someone else besides the current viewer or pageSubject. Does anyone know how to get this thing to work?

The lack of socialengine help and awful api are making this hard.


回答1:


$this->viewer() actually is the logged-in user's object. If your user is not logged in this code won't output anything.

Edit: It is the user object. You can use Engine_Api::_()->user()->getViewer() or if you know the user_id/email of viewer, Engine_Api::_()->user()->getUser($user_id)




回答2:


You could also use: $this->viewer()->getIdentity().




回答3:


This will print image with profile link.

<?php
$member2 = Engine_Api::_()->user()->getUser($user_id);
echo $this->htmlLink($member2->getHref(), $this->itemPhoto($member2, 'thumb.icon'), array('class' => 'placement_members_icon'))

?>

replace $user_id in first line with desired user id.... that you can get easily from any table or user table



来源:https://stackoverflow.com/questions/8609482/socialengine-zend-getting-user-profile-picture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!