Skip to content
Snippets Groups Projects
Commit afc4ef36 authored by Daniele Piaggesi's avatar Daniele Piaggesi
Browse files

applied path 2910589-9, 2887275-2, 2886554-2

parent 599f6014
Branches 8.x-1.x
Tags 8.x-1.0
No related merge requests found
......@@ -57,16 +57,18 @@ function prevnext_entity_extra_field_info() {
if (!empty($enabled_nodetypes)) {
foreach ($enabled_nodetypes as $bundle_key => $bundle_name) {
$extra['node'][$bundle_key]['display']['prevnext_previous'] = [
'label' => t('Previous'),
'description' => t('Previous node indicator'),
'weight' => 50,
];
$extra['node'][$bundle_key]['display']['prevnext_next'] = [
'label' => t('Next'),
'description' => t('Next node indicator'),
'weight' => 50,
];
if (!empty($bundle_name)) {
$extra['node'][$bundle_key]['display']['prevnext_previous'] = [
'label' => t('Previous'),
'description' => t('Previous node indicator'),
'weight' => 50,
];
$extra['node'][$bundle_key]['display']['prevnext_next'] = [
'label' => t('Next'),
'description' => t('Next node indicator'),
'weight' => 50,
];
}
}
}
......@@ -88,7 +90,7 @@ function prevnext_node_view(array &$build, \Drupal\node\Entity\Node $node, \Drup
'#direction' => 'previous',
'#text' => t('Previous'),
'#nid' => $previous_next['prev'],
'#url' => Url::fromUserInput('/node/' . $previous_next['prev'], ['absolute' => TRUE])->toString(),
'#url' => Url::fromUserInput('/node/' . $previous_next['prev'])->toString(),
'#void' => empty($previous_next['prev']),
];
}
......@@ -99,7 +101,7 @@ function prevnext_node_view(array &$build, \Drupal\node\Entity\Node $node, \Drup
'#direction' => 'next',
'#text' => t('Next'),
'#nid' => $previous_next['next'],
'#url' => Url::fromUserInput('/node/' . $previous_next['next'], ['absolute' => TRUE])->toString(),
'#url' => Url::fromUserInput('/node/' . $previous_next['next'])->toString(),
'#void' => empty($previous_next['next']),
];
}
......
......@@ -61,9 +61,14 @@ class PrevnextService implements PrevnextServiceInterface {
*/
protected function getNodesOfType(Node $node) {
$query = $this->queryFactory->get('node');
$bundle = $node->bundle();
$langcode = $node->language()->getId();
$nodes = $query->condition('status', NODE_PUBLISHED)
->condition('type', $node->bundle())
->condition('langcode', $node->language()->getId())
->condition('type', $bundle)
->condition('langcode', $langcode)
->addMetaData('type', $bundle)
->addMetaData('langcode', $langcode)
->addTag('prev_next_nodes_type')
->execute();
return array_values($nodes);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment