Categories
CMS Drupal Mastering Development

How do I add a button with a custom redirect to a node view?

I’d like to add a "More info" button to the bottom of a node view. The button should redirect the user to a URL based on the current node, e.g. node/1/info: /** * Implements hook_node_view * * Add the "More Info" button to idea content */ function implementations_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) { […]

Categories
CMS Drupal Mastering Development

How to add Configuration using ConfigFormBase

I created a simple test module that adds a text banner to all nodes if a checkbox is checked in the form of the modules configuration. Currently it is working halfway as I want. When the checkbox is checked and the configuration is exported the text banner displays on all nodes. So far this is […]

Categories
CMS Drupal Mastering Development

How do I unset a field in a node with the help of hook_node_view?

function test_node_view(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) { updateDisplay($build); } function updateDisplay($build) { unset($build->[‘field_test’]); //I want to Unset this field }