public function TaxonomyDisplayAssociatedDisplayHandlerViews::displayAssociated in Taxonomy display 7
Build our output to be rendered to the user.
Overrides TaxonomyDisplayAssociatedDisplayHandler::displayAssociated
See also
TaxonomyDisplayAssociatedDisplayHandler::displayAssociated()
File
- handlers/
associated/ views.inc, line 24
Class
- TaxonomyDisplayAssociatedDisplayHandlerViews
- Add a display handler that will use the Drupal core method of display.
Code
public function displayAssociated($term, $options = NULL) {
module_load_include('module', 'views');
$build = array();
// The code below essentially mimics views_embed_view() but outputs a
// watchdog error if the view/view display isn't valid.
$view = views_get_view($options['view']);
// If view/view display isn't valid.
if (!$view || !isset($view->display[$options['display']])) {
watchdog('taxonomy_display', 'The view and/or view display for %vocab is missing, go to the <a href="!link">full display page</a> and reconfigure the taxonomy term\'s associated content display.', array(
'%vocab' => $term->vocabulary_machine_name,
'!link' => url('admin/structure/taxonomy/' . $term->vocabulary_machine_name . '/display/full'),
), WATCHDOG_ERROR);
}
elseif ($view
->access($options['display'])) {
// Ensure links stay on taxonomy term page.
$view->override_path = current_path();
// Generate the view's output.
$output = $view
->preview($options['display'], array(
$term->tid,
));
if ($output) {
$build['view'] = array(
'#markup' => $output,
);
}
// Set page title from view's title if desired, and if it has a title set
if ($options['use_view_title'] && $view->build_info['title']) {
drupal_set_title(strtr($view->build_info['title'], $view->build_info['substitutions']), PASS_THROUGH);
}
}
return $build;
}