Hey Guys,
I wrote my own custom index plugin to display my own html/php homepage. And I wanted to add an avatar listing on my index page but am having a little issue. Below is the snippet of code that appears in the body of my index page. It is code based on the <a href="http://community.elgg.org/pg/plugins/project/384692/developer/jdalsem/avatar-wall"> Avatar Wall</a> plugin that I modified. Would you be so kind as to give it a look and see why nothing appears. I did echo Count($users); and it was the correct number of users, so I am getting all the users, but do you know why don't they display when I echo them?
<?php
// Start engine from original plug, don't need it
/* require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); */
$users_max = 1000;
$onlyWithAvatar = "no";
if(empty($onlyWithAvatar) || $onlyWithAvatar == "no")
{$users = get_entities('user','',null,null,$users_max,0);}
else
{$users = get_entities_from_metadata('icontime', '', 'user', '', 0, $users_max);}
$wallIconSize = "small";
shuffle($users);
foreach($vars['users'] as $user){
echo "<a href='" . $user->getURL() . "'><img class='avatars' alt='" . $user->name . "' src='". $user->getIcon($vars['wallIconSize']) . "'></a>";
}
?>
Thanks for the help guys!
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Changefrom the line
foreach($vars['users'] as $user){
to
foreach($users as $user){
echo elgg_view("profile/icon",array('entity' => $user, 'size' => 'small'));
} ?>
Thank you kindly. That works but shows all of their information as well. I just would like to show the avatar only. But since your method is different, I am not sure how the original method I used relates to yours. Thank you for the help!
I used this same code before and a menu appears under each avatar. I never was able to just put the avatars on the front page.
Does anyone knows how to do this?
What would be really cool would be if someone could show show how to access the avatar/icon for each user in the network, so it could be displayed in a table or something. Dreaming...
I tried such thing, did a table and everything, but that menu was still showing. I asked this same thing a long time ago and they only posted the code I was already using...
icondirect.php ?
;-)
Was that a question? Or are you saying, just call icondirect.php?
Just add override in the array for icon view to remove the menu
I'm sorry I am not better at my elgg coding, how do I add override in the array? THanks sooo much!
echo elgg_view("profile/icon",array('entity' => $user, 'size' => 'small', 'override' => 'true'));
- Previous
- 1
- 2
- 3
- 4
- 5
- Next
You must log in to post replies.