Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

This is what helped for me.

http://stackoverflow.com/a/2474164/28672https://stackoverflow.com/a/2474164/28672

Using the second option to generate the view manually then modifying the array in the result property.

And this is the code I used to sort the results to the argument

 // Sort the view based on the argument now we've generated it.
  $results = $view->result;
  $view_argument_array = explode('+', '1099+1100+1102+1098+1101+1097');
  $new_result_order = array();
  foreach ($view_argument_array as $nid) {
    foreach ($results as $result) {
      if ($result->nid == $nid) {
        $new_result_order[] = $result;
      }
    }
  }
  $view->result = $new_result_order;

This is what helped for me.

http://stackoverflow.com/a/2474164/28672

Using the second option to generate the view manually then modifying the array in the result property.

And this is the code I used to sort the results to the argument

 // Sort the view based on the argument now we've generated it.
  $results = $view->result;
  $view_argument_array = explode('+', '1099+1100+1102+1098+1101+1097');
  $new_result_order = array();
  foreach ($view_argument_array as $nid) {
    foreach ($results as $result) {
      if ($result->nid == $nid) {
        $new_result_order[] = $result;
      }
    }
  }
  $view->result = $new_result_order;

This is what helped for me.

https://stackoverflow.com/a/2474164/28672

Using the second option to generate the view manually then modifying the array in the result property.

And this is the code I used to sort the results to the argument

 // Sort the view based on the argument now we've generated it.
  $results = $view->result;
  $view_argument_array = explode('+', '1099+1100+1102+1098+1101+1097');
  $new_result_order = array();
  foreach ($view_argument_array as $nid) {
    foreach ($results as $result) {
      if ($result->nid == $nid) {
        $new_result_order[] = $result;
      }
    }
  }
  $view->result = $new_result_order;
Source Link
Paul Sheldrake
  • 1.2k
  • 4
  • 15
  • 33

This is what helped for me.

http://stackoverflow.com/a/2474164/28672

Using the second option to generate the view manually then modifying the array in the result property.

And this is the code I used to sort the results to the argument

 // Sort the view based on the argument now we've generated it.
  $results = $view->result;
  $view_argument_array = explode('+', '1099+1100+1102+1098+1101+1097');
  $new_result_order = array();
  foreach ($view_argument_array as $nid) {
    foreach ($results as $result) {
      if ($result->nid == $nid) {
        $new_result_order[] = $result;
      }
    }
  }
  $view->result = $new_result_order;