You are here

function rb_misc_action_views_load_node in Rules Bonus Pack 6

Same name and namespace in other branches
  1. 7 rb_misc.rules.inc \rb_misc_action_views_load_node()

The 'rb_misc_action_views_load_node' action.

File

./rb_misc.module, line 327
Miscellaneous conditions and actions for Rules.

Code

function rb_misc_action_views_load_node($settings) {
  $views_settings = explode('|', $settings['view']);
  $view_name = $views_settings[0];
  $display_name = $views_settings[1];
  $view_arguments = explode("\r", $settings['args']);
  $view = views_get_view($view_name);
  $view
    ->set_display($display_name);
  $view
    ->set_arguments($view_arguments);
  $view
    ->set_items_per_page(1);
  $view
    ->execute();
  $results = $view->result;
  $node = node_load($results[0]->nid);
  return array(
    'node' => $node,
  );
}