I installed the "Private Message" module on Drupal 8.
There is a link to send a message that I want to transform into a Bootstrap button.
How to customize a link on Drupal 8 ?
Here is the HTML code of the link :
<div class="private_message_link_wrapper"><a href="/private_messages/9" class="private_message_link">Envoyer un message</a></div>
The developer of "Private Message" gave me this code, but I do not know what to do with it.
I need to create a custom module or put it in my_theme.info.yml
?
function HOOK_node_view_alter(&$build) {
$build['private_message_link']['#title'] = t('Click me. Click me now!');
}
The developer of the module wrote in a comment :
You can implement hook_ENTITY_TYPE_view_alter(). For example, if you are altering the link on the user profile you would implement hook_user_view_alter(). If you are altering the link on nodes, you would implement hook_node_view_alter(). If you are altering the link on comments, you would implement hook_ENTITY_TYPE_view_alter().
In this function, you can change the output of the link by altering $build['private_message_link'] as you see fit.
I created a custom module:
private_message_contact_button.module
:
<?php
/**
* @file
* Hook implementations of private_message_contact_button module.
*/
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
function private_message_contact_button_node_view_alter(&$build) {
$build['private_message_link']['class'] = array('button button--primary', 'btn');
}
The code works, but the button is not applied.
I want to add class btn btn-success
And I want to add an icon make awesome in front of the text <i class="fas fa-comment fa-lg"></i>
I have to put what as code ?