Print All Users - Joomla 2.5

2020-03-26 04:13发布

I am new to Joomla. I have created website using Joomla 2.5. I have login page which is default Joomla user management system.

What I want is display all user data in a tabular format. How could I do the same?

Edit 1

I can see the users with below steps.

  1. Go to administrator page as www.site.com/administrator.
  2. Login as admin
  3. Click Users >> User Manager menu and then I can see the list of users.

I want to print same list, however on the website and not on administrator site at backend.

4条回答
▲ chillily
2楼-- · 2020-03-26 04:39

you can do this run the query on your page where you want to show user list. you can fetch all users table field with $row object.

$db =& JFactory::getDBO();
$query = "SELECT * FROM #__users" ;
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
  echo $row->id.'|'.$row->username.'|'.$row->email;
}

Edit 1

Below is what I used.

Installed extension Flexi Custom Code.

Create module using this, add above code in it and appear that menu on the menu where you want to display.

查看更多
手持菜刀,她持情操
3楼-- · 2020-03-26 04:39

// my example with opt-groups, preselected user and better user-ids

function getUserList ($user_id) {
    $db = JFactory::getDBO ();
    $db->setQuery ("SELECT id, username, usertype FROM ' . $db->quoteName ('#__users') . ' ORDER BY usertype,username ASC");
    $rows = $db->loadAssocList ();
    static $opt_tag;

    $list = '<option value="0">' . JText::_ ('SELECTION') . '</option>';

    foreach ($rows as $row) {
        if (empty ($opt_tag) || $opt_tag != $row['usertype']) {
            $list .= '<optgroup label="' . $row['usertype'] . '">';
            $opt_tag = $row['usertype'];
        }

        if ($row['id'] < 10) {
            $id = '000' . $row['id'];
        }

        elseif ($row['id'] < 100) {
            $id = '00' . $row['id'];
        }

        elseif ($row['id'] < 1000) {
            $id = '0' . $row['id'];
        }

        $list .= '<option value="' . $row['id'] . '"' . (((int) $user_id == $row['id']) ? ' selected="SELECTED"' : '') . '>' . $id . ' - ' . $row['username'] . '</option>';
        if (empty ($opt_tag) || $opt_tag != $row['usertype']) {
            $list .= '</optgroup>';
        }
    }
    return $list;
}
查看更多
Bombasti
4楼-- · 2020-03-26 04:46

You'll need some sort of component for this. This user profile component for example (N.B. Using this as my example as a work colleague once used it - not as customizable as I would have liked - but probably OK for what your after. I'm sure there are more as there's an entire member list category.)

Just install one of them and choose what you want to show. Add it to a menu like any other component and off you go!

查看更多
smile是对你的礼貌
5楼-- · 2020-03-26 05:00

Two possible solutions

  • Use the User Profile Component available in JED
  • Enable "User - Contact Creator" plugin to create a Contact profile for each new user and then use the Joomla built-in Menu Item to list all contacts
查看更多
登录 后发表回答