4

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.

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276

4 Answers4

7

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.

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44
  • I believe what I need to do is create article and there paste this code... right? – Fahim Parkar Oct 09 '12 at 13:32
  • hey I am new to this... could you please tell me what to do?? – Fahim Parkar Oct 09 '12 at 14:13
  • Create a module? why would that be necessary? I probably wouldn't go with this method. The code is correct but you will have major styling to do and will probably want to make each name a link, linking to their profile. I would go with @GeorgeWilson answer and make some minor changes the the default.php to suit your needs. – Lodder Oct 09 '12 at 18:54
1

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!

George Wilson
  • 5,595
  • 5
  • 29
  • 42
  • User Profile is working, however there are un-wanted things in table. how to remove those and add what I want. e.x. email id, mobile number, name, etc – Fahim Parkar Oct 09 '12 at 13:52
  • Yeah you need to edit raw code for that I'm afraid. Hence not as compatible as I like. Mobile number doesn't come as default with Joomla as far as I'm aware. Do you have an extra component installed for that?? – George Wilson Oct 09 '12 at 18:49
1

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
marcanuy
  • 23,118
  • 9
  • 64
  • 113
  • this is working, however there are un-wanted things in table. how to remove those and add what I want. e.x. email id, mobile number, name, etc – Fahim Parkar Oct 09 '12 at 13:51
  • You can select which fields do you want to show/hide at frontend modifying the plugin parameters, if you want to add another ones, you can rename any of them through language files or create your own version of the plugin: [Profile plugin customization](http://docs.joomla.org/Creating_a_profile_plugin) – marcanuy Oct 09 '12 at 18:39
1

// 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;
}
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
breaker
  • 11
  • 1