In Drupal 7, you can use the hook_entity_view_alter() function to alter the rendering of entities before they are displayed. This hook allows you to modify the display of entity content without directly manipulating the entity's template files.
Source code viewer
/** * Implements hook_entity_view_alter(). */ function HOOK_entity_view_alter(&$build, $type) { if ($type == 'node') { // Check if the entity is of a specific bundle (content type). if ($build['#bundle'] == 'article') { // Modify the way the article nodes are displayed. // For example, you can add a custom class to the entity's HTML wrapper. $build['#attributes']['class'][] = 'custom-article-class'; // You can also add additional content to the entity's display. '#markup' => 'This is a custom field added by the entity view alter.', '#weight' => 10, ); } } }Programming Language: PHP