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!

  • Ok. I'll try with your recommandations tomorrow. It's the night here ;).

    Thx for your helps.

  • So, I work on it but it's hard. I find that the user's default profile fields are called like "admin_defined_profile_1, admin_defined_profile_2, etc ...".

    So the first step is to extract the user's avatar and his "admin_defined_profile_1" field.

  • Is it the good way ?

    $options = array(
    'type' => 'user',
    'full_view' => false,
    'limit' => '6',
    'pagination' => 'false',
    'metadata' => '?' ,
    'subtitle' => '?' ,
    );

    $content = elgg_list_entities($options);

    echo $content;

    I don't see how to replace the '?'

     

  • @Stéphane Caillaud

    You don't need to create something a new ;)

    Just copy file views\default\user\default.php into your own theme/plugin and edit it.

    See again at $metadata :

    $metadata = elgg_view_menu('entity', array(
        'entity' => $entity,
        'sort_by' => 'priority',
        'class' => 'elgg-menu-hz',
    ));

    It's just return menu's items like banned/location etc by default viewing

    You may to skip it.

     

    About 'subtitle'..it's a text that you want to see on follow after user's avatar.

     

    Examples:

    Contruction

    $entity->briefdescription

    means a briefdescription from user' profile

    And

    $entity->status

    means a status text from profile

    etc

  • Ok. I'll work on it. I hope that this will lead.

  • Argh! I'm missing one or two concepts to understand how it works. I'm stuck and it's frustrating!

    So I want to include a bloc with a special grid member in my new homepage. The bloc is called like this:

    $member = elgg_view('page/elements/member', $vars);

    <div class="elgg-page-body">
    <div class="elgg-inner">$member</div>
    </div>

    So I copy the "default.php" code in my "member.php" page. If I do it with no change an I display it: I have a blank page. I think it is normal but I can see why ... Could you tell me why?

  • I have a question: why not use the "members/index.php" page?

  • So I code two pages:

    - one "member.php" page,
    - one "grid.php" page.

    Code of the "member.php" page:

    $num_members = get_number_users();

    $title = elgg_echo('members');

    $options = array('type' => 'user', 'full_view' => false);

    $content = elgg_list_entities($options);

    echo elgg_view('members/grid', $content);

    Code of the "grid.php" page:

    in progress (formatting the grid and extracting the metadata inside)

    Is it the good way?

  • So I want to populate this code with the users's list:

    <div>
    <ul>
    // start of the loop
    <li><a href="linkToTheUser">
    <div></div>
    <div>
    <h4>NameOfTheUser</h4>
    <p>FirstUserField</p>
    </div>
    </li>
    </ul>
    // end of the loop
    </div>

    I'm quite lost and I don't know if I follow the RvR's recommandations ...
  • @Stéphane Caillaud Do you like a headache ? :)

    I said about copy views\default\user\default.php into your own theme/plugin BUT not about creating a new file.

    Copy this file and put it like as:

    your_theme\views\default\user\default.php

    This file is displays a user by default. Overriding it you can create your own view for user.

    So, now you need make your own page for showing the users' list. By default, this is a file members/page/index.php.

    Override it with your own page handler e.g.:

    elgg_unregister_page_handler('members', 'members_page_handler');

    elgg_register_page_handler('members', 'my_members_page_handler');

    function my_members_page_handler($page) {

        $base = elgg_get_plugins_path() . 'your_theme/pages/members';
       
         $vars = array();
         $vars['page'] = $page[0];

         if ($page[0] == 'search') {
             require_once "$base/search.php";
         } else {
            require_once "$base/index.php";
         }
            return true;

    }

    Now create the path with folders: pages/members

    And put into 2 your own files: index.php and search.php

    Copy them from default plugin members

    File index.php is your own customizing viewing of members' list. Edit it and add your code.

    I've created 2 example files for U try it:

    default.php - http://z.wzm.me/?5b7ebe84962fa029#yQzLmztXIbhn2JA7ShLTk4ElAbKM86tlwUyohspAL3M=

    index.php - http://z.wzm.me/?f46f922367866c55#T9y0P+39ypx/Eog3efqYnjNHV8K4tnfuOApOhi5uj5A=

    Remember: you need CSS customizing also.

    Best regards!