You are here

function opigno_messaging_preprocess_private_message_thread__full in Opigno messaging 3.x

Implements hook_preprocess_HOOK().

File

./opigno_messaging.module, line 612
Contains opigno_messaging.module.

Code

function opigno_messaging_preprocess_private_message_thread__full(&$variables) {
  $thread = $variables['private_message_thread'] ?? NULL;
  if ($thread instanceof PrivateMessageThreadInterface && $thread
    ->get('private_messages')
    ->isEmpty()) {

    // Add the extra wrapper to display the 1st message without the page reload.
    $variables['content']['private_messages']['#prefix'] .= '<div class="private-message-wrapper"></div>';
  }

  // Update the field suffix to be create an anchor to scroll to.
  $suffix = $variables['content']['private_messages']['#suffix'] ?? '';
  $variables['content']['private_messages']['#suffix'] = '<div class="opigno-messages-scroll-target"></div>' . $suffix;
}