How do you change the order of the fields?
Steve Dondley - November 19, 2007 - 11:18
| Project: | Views Fusion |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I have fused view presented as a table. The columns of the parent view always show before the columns of the child view. Is there a way to change this behavior?

#1
OK, I was able to accomplish this by overriding the theme to the view in template.php:
function unionproud2_views_view_table_yourviewname($view, $nodes, $type) {$desired_order = array(0, 4, 5, 1, 2, 3, 7, 6);
$old_order = $view->field;
$new_order = array();
foreach($desired_order as $index) {
$new_order[] = $old_order[$index];
}
$view->field = $new_order;
$old_order = $view->table_header;
$new_order = array();
foreach($desired_order as $index) {
$new_order[] = $old_order[$index];
}
$view->table_header = $new_order;
return theme_views_view_table($view, $nodes, $type);
}
To use this with any other view:
1. Be sure to change the _yourviewname in the function name to the name of your view.
2. Change the $desired_order array to reflect the order you want the fields to appear. So, if you have five fields and you want to make the first column last and the last column first, you would put:
$desired_order = (4, 1, 2, 3, 0);#2
I tried this and changed
yourviewnameto my view's name but this did not work. Do I need to change anything else (like theunionproud2part)?#3
Yes, change that to phptemplate if it's going in your template.php file.
#4
Still no luck with this. Here's what I've added:
function phptemplate_views_view_table_resourcetype_journals($view, $nodes, $type) {$desired_order = array(0, 4, 5, 1, 2, 3);
$old_order = $view->field;
$new_order = array();
foreach($desired_order as $index) {
$new_order[] = $old_order[$index];
}
$view->field = $new_order;
$old_order = $view->table_header;
$new_order = array();
foreach($desired_order as $index) {
$new_order[] = $old_order[$index];
}
$view->table_header = $new_order;
return theme_views_view_table($view, $nodes, $type);
}
My view's name is "resourcetypes_journals" and I've added it to the following file - /themes/garland/template.php. Right now I'm just using the garland theme so I presume that is the file I need to make the changes to.
Can anyone spot the problem?
Rob
#5
Please don't change the title of an issue.