• Register or
  • Sign In
    • Forgot your password?
    • Forgot your username?
    Or sign in with your account on:
    Facebook
    Twitter
    Google
    LinkedIn

K2 | The powerful content extension for Joomla! developed by JoomlaWorks

  • home
  • about
  • blog
  • documentation
  • extend K2
  • showcase
  • community
  • demo
K2 brings the good parts from Drupal and Wordpress into Joomla!
  • Index
  • Recent Topics
  • Search
Welcome, Guest

To post messages, you need to login first.
K2 Community Forum
K2 Community Forum
New to K2? Ask here first!

Sorting of user list
(1 viewing) (1) Guest
Reply Topic
New Topic
  • Page:
  • 1

TOPIC: Sorting of user list

Sorting of user list 1 year, 4 months ago #7036

  • Egbert Oldenboom
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
I'm using K2 with joomla 1.7. I've made a user list, which I've divided into 3 parts, which I display as columns next to each other (to have a better overview). In fact I now have 3 user lists: A-G, H-M and N-Z.. So far so good, see my website www.kunstinlochem.nl/index.php/2011-10-2.../info-voor-bezoekers

I would like to have these lists alphabetically sorted, and I did so at the back end . In the back end module you can pick specific users and it says "sort with drag and drop" (see the screenshot). This suggests to me that the ordering displayed at the back end is 'leading'. However, this ordering is not visible at the front end, in fact it is a mess and I cannot see any logic in the displayed ordering (not by items/id's/date).

(For the complete list, alphabetical ordering is no problem). What is going wrong here?
KunstinLochem-Administration-GoogleChrome_2012-01-18_12-00-31.png
Reply Quote

Re: Sorting of user list 1 year, 4 months ago #7271

  • Egbert Oldenboom
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
anyone?
Reply Quote

Re: Sorting of user list 1 year, 3 months ago #7693

  • Glen Chancy
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
I am having the same issue. I looked in the module code, and it appears to me that when using a specific list, that is is simply sorting by User ID (lowest to highest). I can't see anyway around this other than simply coding the module to pay attention to the listed order.
Reply Quote

Re: Sorting of user list 10 months, 2 weeks ago #158852

  • Michael
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hello,

some time ago i found the following solution - sorry i cannot remember where, but it works for me:

in "modules/mod_k2_users/helper.php" after (about line 59):
$db->setQuery($query);
$userObjects = $db->loadObjectList();
$newUserObjects = array();


insert the following:

foreach ($IDs as $id) {
foreach ($userObjects as $uO) {
if ($uO->UID == $id) {
$newUserObjects[] = $uO;
break;
}
}
}
$userObjects = $newUserObjects;


hope that helps
Last Edit: 10 months, 2 weeks ago by Michael.
Reply Quote

Re: Sorting of user list 10 months, 2 weeks ago #158862

  • Lefteris Kavadas
  • ( Admin )
  • OFFLINE
  • Administrator
  • Posts: 2221
@Michael

Fix added in the SVN. Thanks for your feedback.
Reply Quote

Re: Sorting of user list 10 months, 1 week ago #159162

  • Greg
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
works awesome in 2.5 also.

for another slightly different solution, I was using the DB query to sort the list by name instead of me having to re-order everybody all the time. I've used the Ordering value from the Filter Section to help drive behavior in the Specific Users section.

FTP to your installation, navigate to the same file
modules/mod_k2_users/helper.php


line 54:
 
// start hack
if ($params->get('ordering')=='alpha') $_alphaHack = true;

$query = "SELECT users.name,users.email, users.id AS UID, profiles.* FROM #__users AS users
LEFT JOIN #__k2_users AS profiles ON users.id=profiles.userID
WHERE users.block=0 AND users.id IN ("
.implode(',',$IDs).")";

if ($_alphaHack) $query.=" ORDER BY users.name ASC";

$db->setQuery($query);
$userObjects = $db->loadObjectList();

// this will sort by how it is listed in the admin console
if (! $_alphaHack) {
$newUserObjects = array();
foreach ($IDs as $id) {
foreach ($userObjects as $uO) {
if ($uO->UID == $id) {
$newUserObjects[] = $uO;
break;
}
}
}
$userObjects = $newUserObjects;
}
// end hack
Last Edit: 10 months, 1 week ago by Greg. Reason: specify the file to modify and make the code block CODE formatted
Reply Quote
Reply Topic
New Topic
  • Page:
  • 1
K2 Community Forum
K2 Community Forum
New to K2? Ask here first!
Find this topic helpful? Why not share it with others?
Tweet
Powered by Kunena
Time to create page: 0.34 seconds
Advertisement
  • Contact us
  • Join the K2 Expert Companies list
  • Privacy Policy
back to top
Copyright © 2006 - 2013 JoomlaWorks Ltd.. All rights reserved. K2 is a joint project by JoomlaWorks Ltd. & Nuevvo Webware Ltd., released under the GNU/GPL v2 license.
Joomla! is a registered trademark of Open Source Matters, Inc. JoomlaWorks/Nuevvo are not affiliated with or endorsed by Open Source Matters or the Joomla! Project.
designed by Nuevvo