7

In Drupal 8, it is easy to add display/view modes. Let say I created the tech display mode and I set it up for the film content type.

Now, I would like to create a route for it and access it as local task of entity.node.canonical.

How can I achieve this?

2 Answers 2

11

In Drupal 8 there are two display modes: view mode and form mode.

You can define the view mode in a route using the _entity_view key.

_entity_view: The value is entity_type.view_mode. Will find an entity in the path and render it in the given view mode. E.g. _entity_view: node.teaser will return the render array of the {node} in teaser mode.

0
1

The View Mode Page module does just what you're looking for, creating alternate paths to access different view modes.

Create separate pages for different view modes for a given content type.

1
  • 1
    The View Mode Page module worked perfectly for what I needed. Thanks for the very helpful tip! Commented Oct 9, 2020 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.