function views_plugin_display_attachment::attach_to in Views (for Drupal 7) 6.2
Same name and namespace in other branches
- 6.3 plugins/views_plugin_display_attachment.inc \views_plugin_display_attachment::attach_to()
- 7.3 plugins/views_plugin_display_attachment.inc \views_plugin_display_attachment::attach_to()
Attach to another view.
Overrides views_plugin_display::attach_to
File
- plugins/
views_plugin_display_attachment.inc, line 206 - Contains the attachment display plugin.
Class
- views_plugin_display_attachment
- The plugin that handles an attachment display.
Code
function attach_to($display_id) {
$displays = $this
->get_option('displays');
if (empty($displays[$display_id])) {
return;
}
if (!$this
->access()) {
return;
}
// Get a fresh view because our current one has a lot of stuff on it because it's
// already been executed.
$view = $this->view
->clone_view();
$view->original_args = $view->args;
$args = $this
->get_option('inherit_arguments') ? $this->view->args : array();
$view
->set_arguments($args);
$view
->set_display($this->display->id);
if ($this
->get_option('inherit_pager')) {
$view->display_handler->use_pager = $this->view->display[$display_id]->handler
->use_pager();
$view->display_handler
->set_option('pager_element', $this->view->display[$display_id]->handler
->get_option('pager_element'));
}
// because of this, it is very very important that displays that can accept
// attachments not also be attachments, or this could explode messily.
$attachment = $view
->execute_display($this->display->id, $args);
switch ($this
->get_option('attachment_position')) {
case 'before':
$this->view->attachment_before .= $attachment;
break;
case 'after':
$this->view->attachment_after .= $attachment;
break;
case 'both':
$this->view->attachment_before .= $attachment;
$this->view->attachment_after .= $attachment;
break;
}
$view
->destroy();
}