Page 1 of 1

How to sort issues by 3 fields in View Issues Page - Urgent

Posted: 18 Jun 2008, 15:28
by mhsieh
Hello Mantis Forums Users!

I'd like to sort issues by 3 different fields in View Issues Page; First sort by Priority, then by Status, then by Date Submitted. Is this possible and how to do it?

Thanks a lot!

Please help,
:D

Re: How to sort issues by 3 fields in View Issues Page - Urgent

Posted: 29 Jun 2008, 20:26
by vboctor
If you go to advanced filters, you can sort by two fields. However, you can't sort by more than 2 fields.

Re: How to sort issues by 3 fields in View Issues Page - Urg

Posted: 23 Mar 2010, 11:28
by philippd
Hi,


I've got the same problem.
I'd like to sort by three cols

Is there any way to reach this? maybe with a plugin or some dirty code added somewhere or is this limited by the database?


Thanks a lot in advance
Philipp

Re: How to sort issues by 3 fields in View Issues Page - Urg

Posted: 23 Mar 2010, 12:24
by atrol
AFAIK there is no plugin for it
You would have to change the code of functions in file core/filter_api.php
Start looking at print_filter_show_sort()

Re: How to sort issues by 3 fields in View Issues Page - Urg

Posted: 16 Oct 2012, 04:49
by shiroamada
core/filter_api.php

Change < 2 to < 3, got 2 places to make the changes.

Code: Select all

$t_sort_fields = explode( ',', $t_filter[FILTER_PROPERTY_SORT_FIELD_NAME] );        
$t_dir_fields = explode( ',', $t_filter[FILTER_PROPERTY_SORT_DIRECTION] );

for( $i = 0;$i < 3;$i++ ) {
Look for this function print_filter_show_sort()
add this line after array[1]

Code: Select all

if( !isset( $t_sort_fields[2] ) ) {
	$t_sort_fields[2] = '';
	$t_dir_fields[2] = '';
}
and also this

Code: Select all

        echo ', ';
        
        # for third sort
		echo '<select name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_2">';
		foreach( $t_shown_fields as $key => $val ) {
			echo '<option value="' . $key . '"';
			check_selected( $key, $t_sort_fields[2] );
			echo '>' . $val . '</option>';
		}
		echo '</select>';
		echo '<select name="', FILTER_PROPERTY_SORT_DIRECTION, '_2">';
		foreach( $t_shown_dirs as $key => $val ) {
			echo '<option value="' . $key . '"';
			check_selected( $key, $t_dir_fields[2] );
			echo '>' . $val . '</option>';
		}
		echo '</select>';
After the else statement as well.

Code: Select all

 echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_2" value="last_updated" />';
		echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_DIRECTION, '_2" value="DESC" />';

view_all_set.php
add another 2 extra variable

Code: Select all

$f_sort_2				= gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME . '_2', 'summary' );
$f_dir_2				= gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION . '_2', 'ASC' );
and also this.

Code: Select all

	$f_sort = ( ( $f_sort_d != "" ) ? $f_sort_d : $f_sort_0 ) . ( ( $f_sort_1 != "" ) ? "," . $f_sort_1 : "" ) . ( ( $f_sort_2 != "" ) ? "," . $f_sort_2 : "" );
	$f_dir = ( ( $f_dir_d != "" ) ? $f_dir_d : $f_dir_0 ) . ( ( $f_dir_1 != "" ) ? "," . $f_dir_1 : "" ) . ( ( $f_dir_2 != "" ) ? "," . $f_dir_2 : "" );
I manage to change this, and I got 3 sorting options :)

Re: How to sort issues by 3 fields in View Issues Page - Urg

Posted: 21 Aug 2015, 13:21
by Adysone
3 years later, it's always efficient, thank you shiroamada!

Re: How to sort issues by 3 fields in View Issues Page - Urgent

Posted: 18 Apr 2019, 09:46
by Horror
I've got the same problem.