Displaying Avatars on Custom Index

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"&gt; 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!

  • I want to create a specific frontpage. I don't think (or i can't see) how this plugins can help me.

    Here is the code for the grid of the members:

    <?php $newest_members = elgg_get_entities_from_metadata(array('metadata_names' => 'icontime', 'types' => 'user', 'limit' => 15));?>
    <h2>The Grid</h2>

    <div>
       <ul>
          <?php
             if(isset($newest_members)) {
             //display member avatars
             foreach($newest_members as $members){
                echo "<li><a href=\"#\">
                <div>";
                   echo elgg_view("profile/icon",array('entity' => $members, 'size' => 'large', 'override' => 'true'));
                   echo "</div><div>
                      <p>Name</p>
                      <p>skill</p>
                   </div>
                   </a></li>";
                }
             }
          ?>
          </ul>
    </div>

    I want to replace the name and the skill by those of the members.

  • @Stéphane Caillaud

    Early, we've used this code for our wallZ:

    $dbprefix = elgg_get_config("dbprefix");
    $limit = get_input("limit", 60);
        
    $content = elgg_list_entities(array(
                    "type" => "user",
                    "full_view" => FALSE,
                    "limit" => $limit,
                    "joins" => array("JOIN " . $dbprefix . "users_entity u ON e.guid=u.guid"),
                    "order_by" => "u.name asc",
                    'list_type' => 'gallery',
                    'list_type_toggle' => false,
                    'gallery_class' => 'elgg-gallery',
                ));

     

    But you can try also:

    $options = array(
            "type" => "user",
            "limit" => 60,
            "relationship" => "member_of_site",
            "relationship_guid" => elgg_get_site_entity()->getGUID(),
            "inverse_relationship" => true,
            "full_view" => false,
            "pagination" => false,
            "list_type" => "users",
            "gallery_class" => "elgg-gallery-users",
            "size" => "small"
        );

    echo elgg_list_entities_from_relationship($options);

     

    Last code from widget manager

  • The widget manager plugin has a widget that can be displayed on the front page that shows new members. You could change the view to show what you need. If you do not yet have the profile fields you need you can use profile manager to add them.  

    The widget can be changed to look how you want it by using css.

  • Ok. It's working. I don't yet change the css. Now I would like to get each user name and each skill (or a specific metadata).

    I look to Wallz. How did you do to write the name for each avatar ?

  • We're not using this look on our website now but I have the archive image of it before:

    Old design of Creatorz page

  • Yes. It is what i want to list: user's avatar and some metadata like name and specific profile fileds.

    With your script i can't see how to extract and to display the metadata ? I display only the user's avatar.

  • elgg_list_entities(); linked with view of ElggEntity (ElggUser) : 'full' or 'summary'

    See file views\default\user\default.php (lines 45-51) and code

    $params = array(
                'entity' => $entity,
                'title' => $title,
                'metadata' => $metadata,
              'subtitle' => $entity->briefdescription,
                'content' => elgg_view('user/status', array('entity' => $entity)),
            );

    Override this code's part and try to play with the bolded arrays