missing fields bug fix

This commit is contained in:
2024-11-05 10:19:31 +01:00
parent cab86fcb11
commit e6271c6624
7 changed files with 59 additions and 83 deletions

View File

@ -27,15 +27,15 @@ class PrevNextSite extends BlockBase {
if ($node) {
$nodetype = $node->getType();
if($nodetype === "site"){
$num = $node->get('field_numero')->getString();
$num = $node->get('field_poid')->getString();
$allSites = \Drupal::entityTypeManager()->getStorage('node')
->loadByProperties(['type' => 'site', 'status' => 1]);
usort($allSites, function($a, $b){
$numA = $a->get('field_numero')->getString();
$numB = $b->get('field_numero')->getString();
$numA = $a->get('field_poid')->getString();
$numB = $b->get('field_poid')->getString();
if ($numA == $numB) {
return 0;
}
@ -44,7 +44,7 @@ class PrevNextSite extends BlockBase {
$prevnode = null;
$nextnode = null;
foreach($allSites as $index => $site){
$n = $site->get('field_numero')->getString();
$n = $site->get('field_poid')->getString();
if($n === $num){
$prevnode = $index - 1 >= 0 ? $allSites[$index - 1] : null;
$nextnode = $index + 1 < count($allSites) ? $allSites[$index + 1] : null;