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

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
mhsieh
Posts: 1
Joined: Jun 18, 2008 6:32 am

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

Post by mhsieh » Jun 18, 2008 10:28 am

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

vboctor
Site Admin
Posts: 1286
Joined: Feb 13, 2005 5:11 pm
Location: Redmond, Washington
Contact:

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

Post by vboctor » Jun 29, 2008 3:26 pm

If you go to advanced filters, you can sort by two fields. However, you can't sort by more than 2 fields.
Migrate your MantisBT to the MantisHub Cloud

philippd
Posts: 3
Joined: Mar 23, 2010 6:25 am

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

Post by philippd » Mar 23, 2010 6:28 am

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

atrol
Site Admin
Posts: 7681
Joined: Mar 26, 2008 4:37 pm
Location: Germany

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

Post by atrol » Mar 23, 2010 7:24 am

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()
Please use Search before posting and read the Manual

shiroamada
Posts: 1
Joined: Oct 15, 2012 9:55 pm

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

Post by shiroamada » Oct 15, 2012 11:49 pm

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 :)

Adysone
Posts: 1
Joined: Aug 21, 2015 8:20 am

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

Post by Adysone » Aug 21, 2015 8:21 am

3 years later, it's always efficient, thank you shiroamada!


Post Reply