Browse Source

display full doi url not just the doi as a link

main
Paul Pound 3 months ago
parent
commit
d697c8e476
  1. 3
      src/Plugin/Field/FieldFormatter/DoiFieldFormatter.php

3
src/Plugin/Field/FieldFormatter/DoiFieldFormatter.php

@ -41,8 +41,9 @@ class DoiFieldFormatter extends FormatterBase {
foreach ($items as $delta => $item) {
$prefix = 'https://doi.org/';
// Assumes all field values are just plain text or strings values and not full doi URLS.
$doiUrl = $prefix . $item->value;
$link = Link::fromTextAndUrl($item->value, Url::fromUri($doiUrl));
$link = Link::fromTextAndUrl($doiUrl, Url::fromUri($doiUrl));
$element[$delta] = [$link->toRenderable()];
}
return $element;

Loading…
Cancel
Save