Flag is not displayed in the custom block content

Created on 9 March 2022, about 3 years ago
Updated 19 February 2025, 2 months ago

Problem/Motivation

Flag link is not displayed if node rendered in custom block or view block is rendered in custom block.

Steps to reproduce

Create a custom block programmatically. Render a view with teasers programmatically :

    $view = Views::getView($viewId);

    if (is_object($view)) {
      $view->setDisplay($displayId);
      $view->setArguments($arguments);
      $view->execute();
      $render = $view->render();

      // Render the view
      $result = \Drupal::service('renderer')->render($render);
    }

   return [
      '#type'   => 'markup',
      '#markup' => $result ,
   ];

Same problem if we render simply a node without views :

    $nid = 10;
    $entity_type = 'node';
    $view_mode = 'teaser';

    $view_builder = \Drupal::entityTypeManager()->getViewBuilder($entity_type);
    $storage = \Drupal::entityTypeManager()->getStorage($entity_type);
    $node = $storage->load($nid);
    $build = $view_builder->view($node, $view_mode);
    $result =  \Drupal::service('renderer')->render($build);

Does anyone have an idea why the links are not displayed ?

🐛 Bug report
Status

Postponed

Component

Flag core

Created by

🇫🇷France kate.k

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.

Production build 0.71.5 2024