You are here

function slickgrid_callback_get_view in Slickgrid 6

Get a views filtered by NIDs

Parameters

string $view_name:

string $display_id:

array $nids:

2 calls to slickgrid_callback_get_view()
slickgrid_callback_undo in ./slickgrid.callbacks.inc
Callback function - log an message
slickgrid_callback_update in ./slickgrid.callbacks.inc

File

./slickgrid.callbacks.inc, line 146

Code

function slickgrid_callback_get_view($view_name, $display_id, $nids) {
  $view = views_get_view($view_name);
  $view
    ->set_display($display_id);

  // Remove all existing arguments - we'll limit result set by NID only
  foreach ($view
    ->get_items('argument') as $id => $arg) {
    $view
      ->set_item($display_id, 'argument', $id, NULL);
  }

  // Add an argument to limit the view to only nids being updated
  $options = array(
    'table' => 'node',
    'field' => nid,
    'break_phrase' => 1,
    // Allow multiple nids,
    'validate_argument_nid_type' => 'nid',
  );
  $view
    ->add_item($display_id, 'argument', 'node', 'nid', $options);
  $view
    ->set_arguments(array(
    implode('+', $nids),
  ));
  $view
    ->pre_execute();
  $view
    ->execute();
  $view
    ->render();
  return $view;
}