You are here

function yoast_seo_entity_view_display_alter in Real-time SEO for Drupal 8

Alter the settings used for displaying an entity.

Parameters

\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display: The entity view display that will be used to display the entity components.

array $context: An associative array containing:

  • entity_type: The entity type, e.g., 'node' or 'user'.
  • bundle: The bundle, e.g., 'page' or 'article'.
  • view_mode: The view mode, e.g., 'full', 'teaser', etc.

File

./yoast_seo.module, line 132
Contains yoast_seo.module.

Code

function yoast_seo_entity_view_display_alter(EntityViewDisplayInterface $display, array $context) {

  // Leave Yoast field labels out of the display.
  if ($context['entity_type'] == 'node' && $context['view_mode'] == 'full') {
    foreach ($display
      ->getComponents() as $name => $options) {
      if ($name == 'field_yoast_seo') {
        $display
          ->removeComponent($name);
      }
    }
  }
}