function metatag_entity_view in Metatag 7
Implements hook_entity_view().
Provides additional argument to allow the display to be forced, to work around problems elsewhere in the APIs.
2 calls to metatag_entity_view()
- metatag_ctools_render_alter in ./
metatag.module - Implements hook_ctools_render_alter().
- metatag_views_post_render in ./
metatag.module - Implements hook_views_post_render().
File
- ./
metatag.module, line 1160 - Primary hook implementations for Metatag.
Code
function metatag_entity_view($entity, $entity_type, $view_mode, $langcode, $force = FALSE) {
// Only run this function once per page load, for an entity which is allowed
// metatags.
static $i_will_say_this_only_once = FALSE;
// Only proceed if this entity object is the page being viewed.
if (_metatag_entity_is_page($entity_type, $entity)) {
// Get the entity's extra information.
list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
// If this entity object isn't allowed meta tags, don't continue.
if (!metatag_entity_supports_metatags($entity_type, $bundle)) {
return;
}
// Some API calls need to force the data loading.
if (!$force) {
// Only run this function once per page load.
if ($i_will_say_this_only_once) {
return;
}
$i_will_say_this_only_once = TRUE;
}
// CTools uses 'page_manager' view mode to indicate the full entity display
// page rather than 'full', so streamline the internal processes.
if ($view_mode == 'page_manager') {
$view_mode = 'full';
}
// Generate metatags output.
if ($output = metatag_generate_entity_metatags($entity, $entity_type, $langcode, $view_mode)) {
$instance = metatag_get_entity_metatags_instance($entity, $entity_type, $bundle);
// We need to register the term's metatags, so we can later fetch them.
// @see metatag_page_build().
metatag_page_set_metatags($instance, $output);
}
}
}