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     1000

When 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      200

As you can see with the template in my theme it views every row, but both Col A and B are in reversed order.

#1

aaron1234nz - May 9, 2009 - 00:39

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.

AttachmentSize
debugger content-field-field_fieldname.tpl_.php_.txt 3.08 KB

#2

edde42 - May 9, 2009 - 01:09

Here you go:

php version:5.2.4
Array ( [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

aaron1234nz - May 9, 2009 - 10:01

That's very strange, the output is as it should be.

#4

edde42 - May 9, 2009 - 16:05

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

aaron1234nz - May 9, 2009 - 21:11

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

edde42 - May 10, 2009 - 14:01

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

aaron1234nz - May 13, 2009 - 12:05

im still very confused by this, but i'll continue to try and isolate the cause of the problem

#8

edde42 - May 13, 2009 - 12:13

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

aaron1234nz - May 15, 2009 - 09:50

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

edde42 - May 15, 2009 - 13:59
Status:active» fixed

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

System Message - May 29, 2009 - 14:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.