vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   "Members who have read thread" question (https://vborg.vbsupport.ru/showthread.php?t=319270)

bazookajoe 06-28-2015 05:15 PM

"Members who have read thread" question
 
Is there a way to display the "members who have read this thread" in alphebetical order rather than random order?

kh99 06-28-2015 05:43 PM

There isn't, but you could add a plugin to sort them. Using hook showthread_whoread_list, you could use code something like this:

PHP Code:

if (!function_exists('wrt_compare_username'))
{
   function 
wrt_compare_username($u1$u2) { return strcmp($u1['username'], $u2['username']); }
}

uasort($wrtlist'wrt_compare_username'); 


(but I haven't tested it at all).

MarkFL 06-28-2015 06:24 PM

Kevin, that in fact does correctly sort by username, however it does not ensure that all but the last name has a trailing comma. :)

kh99 06-28-2015 06:46 PM

Quote:

Originally Posted by MarkFL (Post 2548841)
Kevin, that in fact does correctly sort by username, however it does not ensure that all but the last name has a trailing comma. :)

Oh, OK, do you know how to fix it? I just typed it in without even checking to see if it had typos or anything. :) Feel free to post a better one.

MarkFL 06-28-2015 09:06 PM

I briefly tried earlier, but will give it a better go tonight when I am in for the night. :D

Paul M 06-28-2015 09:20 PM

If you replace this ;

PHP Code:

uasort($wrtlist'wrt_compare_username'); 


With this ;

PHP Code:

$wrtlist[$count]['comma'] = $vbphrase['comma_space'];
uasort($wrtlist'wrt_compare_username');
$wrtlist[$count]['comma'] = ''


I *think* it will sort out the commas for you.

MarkFL 06-29-2015 12:36 AM

This is what I wound up doing, only executing the sort if the user can see the data and I wanted a case-insensitive sort as well:

PHP Code:

if ($show['wrt'])
{

    if (!
function_exists('wrt_compare_username'))
    {
        function 
wrt_compare_username($u1$u2) { return strcmp(strtolower($u1['username']), strtolower($u2['username'])); }
    }

    
$wrtlist[count($wrtlist)]['comma'] = ',';
    
usort($wrtlist'wrt_compare_username');
    
$wrtlist[count($wrtlist)-1]['comma'] = '';


I used usort() so that the keys would not be preserved, otherwise you wouldn't know which is last after the sort. :D

--------------- Added [DATE]1435563569[/DATE] at [TIME]1435563569[/TIME] ---------------

I have created a product based off of the ideas in this thread here (thank you Kevin and Paul for your contribution :)):

Sort Who Read Thread Users

That product will allow you to sort the users either by userid, username, or dateline. :)


All times are GMT. The time now is 05:13 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02176 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete