Download & Extend

How do you change the order of the fields?

Project:Views Fusion
Version:5.x-1.2
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

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?

Comments

#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 yourviewname to my view's name but this did not work. Do I need to change anything else (like the unionproud2 part)?

#3

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

#4

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

Title:Still No Luck» How do you change the order of the fields?

Please don't change the title of an issue.

nobody click here