function glazed_helper_node_view in Glazed Theme Helper 8
Implements hook_ENTITY_TYPE_view() for node entities.
File
- ./
glazed_helper.module, line 73 - Module file for glazed_helper.
Code
function glazed_helper_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
// Only add the pager if it should be used for this node's content type.
if (\Drupal::service('flippy.pager')
->flippy_use_pager($node)) {
$build['flippy_pager'] = [
'#theme' => 'flippy',
'#weight' => 50,
'#list' => \Drupal::service('flippy.pager')
->flippy_build_list($node),
'#node' => $node,
];
if (is_object($node)) {
// Add the previous/next elements to the page head, if enable for this
// content type.
if (\Drupal::config('flippy.settings')
->get('flippy_head_' . $node
->getType())) {
$links = \Drupal::service('flippy.pager')
->flippy_build_list($node);
if (!empty($links['prev']['nid'])) {
$build['#attached']['html_head_link'][][] = [
'rel' => 'prev',
'href' => Url::fromRoute('entity.node.canonical', [
'node' => $links['prev']['nid'],
])
->toString(),
];
}
if (!empty($links['next']['nid'])) {
$build['#attached']['html_head_link'][][] = [
'rel' => 'next',
'href' => Url::fromRoute('entity.node.canonical', [
'node' => $links['next']['nid'],
])
->toString(),
];
}
}
}
}
}