You are here

function node_page_top in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/node/node.module \node_page_top()
  2. 9 core/modules/node/node.module \node_page_top()

Implements hook_page_top().

File

core/modules/node/node.module, line 724
The core module that allows content to be submitted to the site.

Code

function node_page_top(array &$page) {

  // Add 'Back to content editing' link on preview page.
  $route_match = \Drupal::routeMatch();
  if ($route_match
    ->getRouteName() == 'entity.node.preview') {
    $page['page_top']['node_preview'] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'node-preview-container',
          'container-inline',
        ],
      ],
    ];
    $form = \Drupal::formBuilder()
      ->getForm('\\Drupal\\node\\Form\\NodePreviewForm', $route_match
      ->getParameter('node_preview'));
    $page['page_top']['node_preview']['view_mode'] = $form;
  }
}