Skip to main content
deleted 24 characters in body
Source Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

I'm sure that this is not the best option but at least it works.

Go to admin/structure/types/manage/YOUR_CONTENT_TYPE/display and select the Title Formatter for your field, and then use this code:

  $nid = 76;
  $node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm($node->field_aaaa->view('full')[$i]['#markup']);
  }

You will see this:

* id_string1
* String 1
* id_string2
* String 2
* id_string3
* String 3

EDIT: The correct way using the @4k4 answer is:

  $nid = 76;
  $node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm((string) \Drupal::service('renderer')->render($delta->view(array('type' => 'title_formatter'))));
  }

I'm sure that this is not the best option but at least it works.

Go to admin/structure/types/manage/YOUR_CONTENT_TYPE/display and select the Title Formatter for your field, and then use this code:

  $nid = 76;
  $node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm($node->field_aaaa->view('full')[$i]['#markup']);
  }

You will see this:

* id_string1
* String 1
* id_string2
* String 2
* id_string3
* String 3

EDIT: The correct way using the @4k4 answer is:

  $nid = 76;
  $node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm((string) \Drupal::service('renderer')->render($delta->view(array('type' => 'title_formatter'))));
  }

I'm sure that this is not the best option but at least it works.

Go to admin/structure/types/manage/YOUR_CONTENT_TYPE/display and select the Title Formatter for your field, and then use this code:

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $i => $delta) {   
  dpm($delta->value);
  dpm($node->field_aaaa->view('full')[$i]['#markup']);
}

You will see this:

* id_string1
* String 1
* id_string2
* String 2
* id_string3
* String 3

EDIT: The correct way using the @4k4 answer is:

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $i => $delta) {   
  dpm($delta->value);
  dpm((string) \Drupal::service('renderer')->render($delta->view(array('type' => 'title_formatter'))));
}
added 32 characters in body
Source Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

I'm sure that this is not the best option but at least it works.

Go to admin/structure/types/manage/YOUR_CONTENT_TYPE/display and select the Title Formatter for your field, and then use this code:

  $nid = 76;
  $node = Drupal\node\Entity\Node\Drupal::loadservice('entity.manager')->getStorage('node')->load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm($node->field_aaaa->view('full')[$i]['#markup']);
  }

You will see this:

* id_string1
* String 1
* id_string2
* String 2
* id_string3
* String 3

EDIT: The correct way using the @4k4 answer is:

  $nid = 76;
  $node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm((string) \Drupal::service('renderer')->render($delta->view(array('type' => 'title_formatter'))));
  }

I'm sure that this is not the best option but at least it works.

Go to admin/structure/types/manage/YOUR_CONTENT_TYPE/display and select the Title Formatter for your field, and then use this code:

  $nid = 76;
  $node = Drupal\node\Entity\Node::load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm($node->field_aaaa->view('full')[$i]['#markup']);
  }

You will see this:

* id_string1
* String 1
* id_string2
* String 2
* id_string3
* String 3

I'm sure that this is not the best option but at least it works.

Go to admin/structure/types/manage/YOUR_CONTENT_TYPE/display and select the Title Formatter for your field, and then use this code:

  $nid = 76;
  $node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm($node->field_aaaa->view('full')[$i]['#markup']);
  }

You will see this:

* id_string1
* String 1
* id_string2
* String 2
* id_string3
* String 3

EDIT: The correct way using the @4k4 answer is:

  $nid = 76;
  $node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm((string) \Drupal::service('renderer')->render($delta->view(array('type' => 'title_formatter'))));
  }
Source Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

I'm sure that this is not the best option but at least it works.

Go to admin/structure/types/manage/YOUR_CONTENT_TYPE/display and select the Title Formatter for your field, and then use this code:

  $nid = 76;
  $node = Drupal\node\Entity\Node::load($nid);
  foreach ($node->field_aaaa as $i => $delta) {   
    dpm($delta->value);
    dpm($node->field_aaaa->view('full')[$i]['#markup']);
  }

You will see this:

* id_string1
* String 1
* id_string2
* String 2
* id_string3
* String 3