在窗口小部件中获取对象的照片 - SocialEngine窗口小部件

时间:2017-10-27 05:06:05

标签: php widget socialengine

我是SocialEngine的初学者,我想知道是否有办法在小部件中获取对象的照片。 就像我知道我们可以使用以下代码获取对象的照片。

//在控制器中

$table  = Engine_Api::_()->getDbTable("mytable","module");
$select = $table->select()->where->("table_id", 1);
$fetch  = $table->fetchRow($select);
$this->view->fetch = $fetch;

//在视图中

echo $this->itemPhoto($this->fetch, "thumb.normal"); 

上面的行将生成图像,否则将加载默认图像。

但是这行代码在widget中不起作用。 我非常感谢你的帮助。

1 个答案:

答案 0 :(得分:0)

您需要确保传递给$this->itemPhoto的第一个参数是User个实例: $this->itemPhoto($user, 'thumb.normal', $user->getTitle())

似乎在你的情况下,$ this-> fetch只是一个Row。您可以使用以下代码创建用户:Engine_Api::_()->getItem('user', $user_id);。希望这会有所帮助。

相关问题