I always prefer to have control in code over my settings on my website. When I have to add some message on top of a view, I do it this way. The trick is to use the Markup class if you want to add HTML of all sorts:

use Drupal\Core\Render\Markup; // on top of file

 * Add a message before the customer view
 * Implements template_preprocess_views_view().
function MYMODULEORTHEME_preprocess_views_view(&$vars) {
  $view = $vars["view"];
  if($view->storage->id() == 'customer_overview') {
    $markup = Markup::create("<div class='messages messages--warning'>Only verified customers are listed here.</div>");
    $vars['header'] = $markup;





Saved you some valuable time?


Donate and get more free time-saving code on this website in the future.