''); $options['inherit_arguments'] = array('default' => FALSE, 'bool' => TRUE); $options['inherit_title'] = array('default' => FALSE, 'bool' => TRUE); $options['inherit_title_strip_tags'] = array('default' => FALSE, 'bool' => TRUE); return $options; } /** * Default options form that provides the label widget that all fields * should have. */ function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $view_display = $this->view->name . ':' . $this->view->current_display; $options = array('' => t('-Select-')); $options += views_get_views_as_options(FALSE, 'all', $view_display, FALSE, TRUE); $form['view_to_insert'] = array( '#type' => 'select', '#title' => t('View to insert'), '#default_value' => $this->options['view_to_insert'], '#description' => t('The view to insert into this area.'), '#options' => $options, ); $form['inherit_arguments'] = array( '#type' => 'checkbox', '#title' => t('Inherit contextual filters'), '#default_value' => $this->options['inherit_arguments'], '#description' => t('If checked, this view will receive the same contextual filters as its parent.'), ); $form['inherit_title'] = array( '#type' => 'checkbox', '#title' => t('Inherit title'), '#default_value' => $this->options['inherit_title'], '#description' => t('If checked, this view will pass its title to its parent (with first row token replacements if applicable). '), ); $form['inherit_title_strip_tags'] = array( '#type' => 'checkbox', '#title' => t('Strip tags from the inherit title'), '#default_value' => $this->options['inherit_title_strip_tags'], '#description' => t('Strip tags from the title. If applicable this view will get any first row tokens replaced and those tokens could contain tags. Strip tags is useful in cases where the title is displayed only in plain text (As panel pane).'), '#dependency' => array( 'edit-options-inherit-title' => array(1), ), ); } /** * Render the area */ function render($empty = FALSE) { if ($view = $this->loadView()) { if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) { return $view->preview(NULL, $this->view->args); } else { return $view->preview(NULL); } } return ''; } /** * Loads the used view for rendering. * * @return \view|NULL * The loaded view or NULL, in case the view was not loadable / recursion * got detected / access got denied. */ protected function loadView() { if (empty($this->options['view_to_insert'])) { return NULL; } list($view_name, $display_id) = explode(':', $this->options['view_to_insert']); $view = views_get_view($view_name); if (empty($view) || !$view->access($display_id)) { return NULL; } $view->set_display($display_id); // Avoid recursion. $view->parent_views += $this->view->parent_views; $view->parent_views[] = "$view_name:$display_id"; // Check if the view is part of the parent views of this view. $search = "$view_name:$display_id"; if (in_array($search, $this->view->parent_views)) { drupal_set_message(t("Recursion detected in view @view display @display.", array('@view' => $view_name, '@display' => $display_id)), 'error'); return NULL; } //Inherit Title $args = array(); if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) { $args = $this->view->args; } if (!empty($this->options['inherit_title'])){ $view->preview($display_id, $args); $inherit_title = $view->get_title(); //Strip tags for the cases where the title is displayed only as plain text. if (!empty($this->options['inherit_title_strip_tags']) && !empty($this->options['inherit_title'])){ $inherit_title = strip_tags($inherit_title); } $this->view->set_title($inherit_title); } return $view; } }