You are here

function file_entity_view_page in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.pages.inc \file_entity_view_page()
  2. 7 file_entity.pages.inc \file_entity_view_page()

Menu callback; view a single file entity.

3 string references to 'file_entity_view_page'
file_entity_file_view_menu_alter in plugins/tasks/file_view.inc
Callback defined by page_manager_file_view_page_manager_tasks().
file_entity_file_view_page in plugins/tasks/file_view.inc
Entry point for our overridden file view.
file_entity_menu in ./file_entity.module
Implements hook_menu().

File

./file_entity.pages.inc, line 11
Supports file operations including View, Edit, and Delete.

Code

function file_entity_view_page($file) {
  drupal_set_title($file->filename);
  $uri = entity_uri('file', $file);

  // Set the file path as the canonical URL to prevent duplicate content.
  drupal_add_html_head_link(array(
    'rel' => 'canonical',
    'href' => url($uri['path'], $uri['options']),
  ), TRUE);

  // Set the non-aliased path as a default shortlink.
  drupal_add_html_head_link(array(
    'rel' => 'shortlink',
    'href' => url($uri['path'], array_merge($uri['options'], array(
      'alias' => TRUE,
    ))),
  ), TRUE);
  return file_view($file, 'full');
}