You are here

function slickgrid_get_view in Slickgrid 7

Same name and namespace in other branches
  1. 7.2 slickgrid.module \slickgrid_get_view()

Get a views filtered by NIDs

Parameters

string $view_name:

string $display_id:

array $nids:

4 calls to slickgrid_get_view()
slickgrid_callback_add in includes/slickgrid.callbacks.inc
Callback function - add an entity
slickgrid_callback_clone in includes/slickgrid.callbacks.inc
Callback function - clone an entity
slickgrid_callback_undo in includes/slickgrid.callbacks.inc
Callback function - undo (revert nodes)
slickgrid_editors::get_result in plugins/editors/handler.class.php

File

./slickgrid.module, line 444

Code

function slickgrid_get_view($view_name, $display_id, $entity_ids = array()) {
  $view = views_get_view($view_name);
  $view
    ->set_display($display_id);

  // Remove all existing arguments - they won't be passed in by the URL anyway
  foreach ($view
    ->get_items('argument') as $id => $arg) {
    $view
      ->set_item($display_id, 'argument', $id, NULL);
  }

  // If there are entity IDs specified, add arguments to return only these ones
  if (count($entity_ids)) {

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