function tvi_render_view in Taxonomy Views Integrator 7
Same name and namespace in other branches
- 6 tvi.module \tvi_render_view()
Replace taxonomy page callback.
If more or less than one term is given then pass the request off to the original taxonomy module page callback.
Parameters
int|object $tid: The term tid or the term object.
null|int $depth: The shown depth.
Return value
array The build array.
1 string reference to 'tvi_render_view'
- tvi_menu_alter in ./
tvi.module - Implements hook_menu_alter().
File
- ./
tvi.module, line 223 - Allow to define views to be used instead of default drupal behavior on taxonomy terms pages.
Code
function tvi_render_view($tid, $depth = NULL) {
if (is_object($tid)) {
$tid = $tid->tid;
}
list($view, $display, $term, $settings) = tvi_get_view_info($tid);
// Load metatags if needed.
if (module_exists('metatag')) {
metatag_entity_view($term, 'taxonomy_term', 'full', NULL);
}
if (is_object($view) && $display) {
$output = t('There was no content found matching this term.');
if (isset($settings->pass_arguments) && $settings->pass_arguments == 1) {
// Pass all arguments to views. Exclude /taxonomy/term.
$args = array_slice(arg(), 2);
}
else {
$args = array(
$tid,
);
if (NULL !== $depth) {
$args[] = $depth;
}
}
if ($view->display[$display]->display_plugin == 'block') {
// If it's a block display, views returns a block array which won't work
// as a page callback so we need to explicitly set the page title
// and just return the $block['content'].
$block = $view
->execute_display($display, $args);
drupal_set_title(filter_xss_admin($block['subject']), PASS_THROUGH);
$output = $block['content'];
}
else {
global $language;
module_invoke_all('entity_view', $term, 'taxonomy_term', 'full', $language->language);
$output = $view
->execute_display($display, $args);
}
return $output;
}
// Taxonomy is last resort - used if no standard views are found.
module_load_include('inc', 'taxonomy', 'taxonomy.pages');
return taxonomy_term_page($term);
}