How to display the rendered entity of the user ?

Created on 20 October 2018, over 5 years ago
Updated 14 February 2024, 4 months ago

When I install the Message Example submodule, it is possible to display the rendered entity of a node with the token [node-render].

How to make a user view mode?

What code should I add for in message_activity_stream.tokens.inc to do this ?

πŸ’¬ Support request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡«πŸ‡·France zenimagine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    You need to add an entry to hook_token_info for user-render.
    In hook_tokens something like this:

    case 'user-render':
      $entity = $message->getOwner();
      $view_builder = \Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId());
      $message_view = $view_builder->view($entity, 'teaser');
      $replacements[$original] = \Drupal::service('renderer')->renderRoot($message_view);
      break;
    
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024