I use the Smart Trim formatter on a paragraphs field (https://drupal.org/project/paragraphs). The paragraph entity is used as field in a node content type.

The Smart Trim formatter tries to link to the paragraphs entity (where the field with the Smart Trim formatter is used). But in the paragraphs entity plugin definition there is no link information defined.

So I get the twig error:

Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template 'canonical' found for the 'paragraph' entity type in Drupal\Core\Entity\Entity->toUrl() (line 214 of core/lib/Drupal/Core/Entity/Entity.php).
Drupal\smart_trim\Plugin\Field\FieldFormatter\SmartTrimFormatter->viewElements(Object, 'de') (Line: 80)
Drupal\Core\Field\FormatterBase->view(Object, NULL) (Line: 259)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 303)
Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'preview') (Line: 246)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 203)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
.....
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cbeier created an issue. See original summary.

cbeier’s picture

My current solution / A solution for me is to check if a valid link template is available for the current entity.

maartendeblock’s picture

Status: Active » Reviewed & tested by the community

I've tested the patch on drupal 8.1.2 and it works.

Thank you.

  • markie committed 642ad2e on 8.x-1.x authored by cbeier
    Issue #2736839 by cbeier: Twig exception if Smart Trim is used on a...
markie’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

@cbeier thanks for the patch. I have applied it to the dev branch. I did correct a formatting error, NULL needs to be capitalized to conform with Drupal standards. Thanks again for your contribution.

markie’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

casey’s picture

Attaching patch so we can apply it to the stable release. Isn't it time for a new stable release?

Anybody’s picture

We've just run into this issue... there should be a new stable release ASAP please fixing this. Is there an active maintainer?