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

Steve Dondley - November 19, 2007 - 12:04

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

rgraves - February 25, 2008 - 16:53

I tried this and changed yourviewname to my view's name but this did not work. Do I need to change anything else (like the unionproud2 part)?

#3

Steve Dondley - February 26, 2008 - 19:05

Yes, change that to phptemplate if it's going in your template.php file.

#4

rgraves - February 28, 2008 - 19:14
Title:How do you change the order of the fields?» Still No Luck

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

Steve Dondley - March 30, 2008 - 17:01
Title:Still No Luck» How do you change the order of the fields?

Please don't change the title of an issue.

 
 

Drupal is a registered trademark of Dries Buytaert.