Theming screws up output
edde42 - May 7, 2009 - 13:09
| Project: | Matrix Field |
| Version: | 6.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Don't know which component to set this for...
I have played a bit with the theming, the previous dev version did it correct, but the latest screws up the output, the data cells are sorted in the wrong order:
Without copying the two tpl's to my theme it looks like this, which is correct:
Col A Col B
Prod A 150 200
Prod B 280 360
Prod C - 450
Prod D 1000 1000When just copying the templates and rename the matrix template to my matrix field name it looks like this:
Col A Col B
Prod A - -
Prod B 1,000 1,000
Prod C - 450
Prod D 280 360
Prod E 150 200As you can see with the template in my theme it views every row, but both Col A and B are in reversed order.

#1
That's weird.
I cannot see any reason why this should happen, but I have come across similar behaviour before, but could never replicate it myself. I've attached a theme template which will output some debug information. Can you run this then post the output back in this issue please.
#2
Here you go:
php version:5.2.4Array ( [0] => Array ( [0] => row_index:integercol_index:integerval:string
[1] => row_index:integercol_index:integerval:string
[2] => row_index:integercol_index:integerval:string
) [1] => Array ( [0] => row_index:integercol_index:integerval:string
[1] => row_index:integercol_index:integerval:string
[2] => row_index:integercol_index:integerval:string
) [2] => Array ( [0] => row_index:integercol_index:integerval:string
[1] => row_index:integercol_index:integerval:string
[2] => row_index:integercol_index:integerval:string
) [3] => Array ( [0] => row_index:integercol_index:integerval:string
[1] => row_index:integercol_index:integerval:string
[2] => row_index:integercol_index:integerval:string
) [4] => Array ( [0] => row_index:integercol_index:integerval:string
[1] => row_index:integercol_index:integerval:string
[2] => row_index:integercol_index:integerval:string
) [5] => Array ( [0] => row_index:integercol_index:integerval:string
[1] => row_index:integercol_index:integerval:string
[2] => row_index:integercol_index:integerval:string
) )
#3
That's very strange, the output is as it should be.
#4
Yes, strange. I have checked the HTML output and it is the same there.
I assume it is using the same tpl.php in the module folder when I don't override it?
Just asking since I noticed that the hard coded red style in the tpl.php only showed up when copying it to my theme when it was working before.
#5
The tpl.php file is only used when it is overridden (its the way cck works). Otherwise it uses this code:
<?php
function theme_matrix_formatter_default($element) {
$field_info = $element['#node']->$element['#field_name'];
$prepared = matrix_format_prepare($field_info);
$links = matrix_format_prepare_links($element['#node']->nid, $element['#field_name']);
//if you want to customize the formatting, manipulate $prepared before passing it to theme('matrix_table'...)
$output = theme('matrix_table', $prepared);
$output .= '<div class="matrix-links">'. $links .'</div>'; //eg export link
return $output;
}
?>
#6
Just downloaded and tested the latest dev version. Tried both with and without the ksort and it did nothing to change the output.
Both problems; empty rows showing and it is sorted in wrong order remains with or without ksort.
#7
im still very confused by this, but i'll continue to try and isolate the cause of the problem
#8
Thanks mate, glad your not giving up. I can tell I have learned quite a bit about Drupal modules trying to figure out what is going on here... I'll do what I can from my side so we hopefully are able to find the problem soon.
#9
I've had another idea about this. check the latest version and see if it works better. I can't reproduce this issue on my system which makes it really hard to debug.
#10
Aaron, I am very happy to report that the latest dev finally nailed it. The field is now viewed correct, both regards the sort order and it works perfectly with hide empty cells on and off.
Thanks for hanging in there mate, fantastic work.
#11
Automatically closed -- issue fixed for 2 weeks with no activity.