by Subhojit Paul
name: 'Hello world'
description: 'Hello World Drupal 8'
type: module
core: 8.x
<?php
/**
* @file
* Implements hello_world module.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
/**
* Implements hook_node_view_alter().
*/
function hello_world_node_view_alter(&$build, $node, $display, $view_mode, $langcode) {
if ($node->getType() == 'article') {
$build['hello_world_new_content'] = array(
'#markup' => t('Hello World!'),
);
}
}
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
function hello_world_node_view_alter(&$build, $node, $display, $view_mode, $langcode) {
// My code.
}
Drupal\Core\Entity\EntityInterface
Drupal\Core\Entity\Display\EntityViewDisplayInterface
subhojitpaul21@gmail.com